Javascript Articles

Page 525 of 534

How to find whether a browser supports JavaScript or not?

vanithasree
vanithasree
Updated on 30-Sep-2019 1K+ Views

To find whether the browser supports JavaScript or nor, use the tag. The HTML tag is used to handle the browsers, which do recognize tag but do not support scripting. This tag is used to display an alternate text message.Here’s an example,           HTML noscript Tag                                              Your browser does not support JavaScript!          

Read More

Should I include language="javascript" in my SCRIPT tags?

mkotla
mkotla
Updated on 30-Sep-2019 540 Views

The language attribute in JavaScript is optional since the introduction of HTML5 brought some new improvements. JavaScript became the default language for HTML5 and modern browsers. Therefore, now adding javascript isn’t required in tag.This attribute specifies what scripting language you are using. Typically, its value will be javascript. Although recent versions of HTML (and XHTML, its successor) have phased out the use of this attribute.Here you can see how it is used:                              

Read More

What does the leading semicolon in JavaScript libraries do?

mkotla
mkotla
Updated on 30-Sep-2019 336 Views

A function in JavaScript looks like the following:(function(){...})()A library in JavaScript shows a function, which begins with a semicolon, for example:;(function ) { }The semicolon allows to safely concatenate several JS files into one. This is to serve it faster as one HTTP request.A leading semicolon can also be to protect from preceding code, which may have been improperly closed. A semicolon will definitely prevent this from happening.

Read More

How I can show JavaScript alert box in the middle of the screen?

Giri Raju
Giri Raju
Updated on 25-Sep-2019 2K+ Views

To show the JavaScript alert box in the middle, you need to use the custom alert box. Under that, style it accordingly and position it to the center. Use the "top" and "left" CSS properties to achieve this. Set them as 50%, but as you can see a button below, use the property to 40% to align it with the button: Example                 function functionAlert(msg, myYes) {       var confirmBox = $("#confirm");       confirmBox.find(".message").text(msg);       confirmBox.find(".yes").unbind().click(function() {         confirmBox.hide();       });       confirmBox.find(".yes").click(myYes);       confirmBox.show();      }              #confirm {       display: none;       background-color: #F3F5F6;       color: #000000;       border: 1px solid #aaa;       position: ...

Read More

How to allocate memory in Javascript?

Ayush Gupta
Ayush Gupta
Updated on 19-Sep-2019 583 Views

Regardless of the programming language, memory life cycle is pretty much always the same −Allocate the memory you needUse the allocated memory (read, write)Release the allocated memory when it is not needed anymoreThe second part is explicit in all languages. Use of allocated memory needs to be done by the developer.The first and last parts are explicit in low-level languages like C but are mostly implicit in high-level languages like JavaScript.Hence there is no explicit way to allocate or free up memory in JavaScript. Just initializing objects allocates memory for them. When the variable goes out of scope, it is ...

Read More

Explain the event flow process in Javascript

Ayush Gupta
Ayush Gupta
Updated on 19-Sep-2019 882 Views

In the JavaScript, Event Flow process is completed by three concepts −Event Target − The actual DOM object on which the event occured.Event Bubbling − Explained belowEvent Capturing − Explained belowEvent bubbling is the order in which event handlers are called when one element is nested inside a second element, and both elements have registered a listener for the same event (a click, for example). With bubbling, the event is first captured and handled by the innermost element and then propagated to outer elements.With capturing, the event is first captured by the outermost element and propagated to the inner elements.Let's ...

Read More

How to create a custom object in JavaScript?

vanithasree
vanithasree
Updated on 19-Sep-2019 558 Views

To create a custom object in JavaScript, try the following code Example                 var dept = new Object();      dept.employee = "Amit";      dept.department = "Technical";      dept.technology = "Java";      document.getElementById("test").innerHTML =      dept.employee + " is working on " + dept.technology + " technology.";       

Read More

How to use OR condition in a JavaScript IF statement?

Abhinanda Shri
Abhinanda Shri
Updated on 19-Sep-2019 5K+ Views

To use OR condition in JavaScript IF statement, use the || operator i.e Logical OR operator. If any of the two operands are non-zero, then the condition becomes true. Here's how you can use the operator || in JavaScript Example             var a = true;      var b = false;      document.write("(a || b) => ");      result = (a || b);      document.write(result);       

Read More

How to convert a string to camel case in JavaScript?

Ayush Gupta
Ayush Gupta
Updated on 19-Sep-2019 1K+ Views

Camel case is the practice of writing phrases such that each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation. For example, Concurrent hash maps in camel case would be written as −ConcurrentHashMapsWe can implement a method to accept a string in JavaScript to convert it to camel case in the following way −Examplefunction camelize(str) {    // Split the string at all space characters    return str.split(' ')       // get rid of any extra spaces using trim       .map(a => a.trim())     ...

Read More

What is the difference between == and === in JavaScript?

Daniol Thomas
Daniol Thomas
Updated on 18-Sep-2019 1K+ Views

Double equals (==) is abstract equality comparison operator, which transforms the operands to the same type before making the comparison. For example,4    ==  4        // true '4'  ==  4        //true 4    == '4'       // true 0    == false     // trueTriple equals (===) are strict equality comparison operator, which returns false for different types and different content.For example,4 === 4  // true 4 === '4' // false var v1 = {'value':'key'}; var v2 = {'value': 'key'}; v1 === v2 //false

Read More
Showing 5241–5250 of 5,339 articles
« Prev 1 523 524 525 526 527 534 Next »
Advertisements