Javascript Articles

Page 533 of 534

What is function overloading in JavaScript?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 2K+ Views

JavaScript does not support Function Overloading. The following shows function overloading − function funcONE(x,y) { return x*y; } function funcONE(z) { return z; } The above will not show an error, but you won't get desired results. On calling, // prints 5 funcONE(5); // prints 5, not 30 funcONE(5,6); JavaScript does not support function overloading natively. If we will add functions with the same name and different arguments, it considers the last defined function.

Read More

How to use comments to prevent JavaScript Execution?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 336 Views

If you want another code while working in the same code document, then use comments. Comment the previous code and add the alternative code to test it. After the testing completes, uncomment the previous code. In this way, you can test both the codes. While using comments follow the below rules to create valid comments − Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript. Any text between the characters /* and */ is treated as a comment. This may span multiple lines. JavaScript also recognizes the ...

Read More

How to debug obfuscated JavaScript?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 669 Views

To debug obfuscated JavaScript code, you need to use a JavaScript formatter or beautifier. Go to the following link to beautify JavaScript, In the left section, add your obfuscated JavaScript code and click Beautify as shown below, On clicking, you can see Beautified JavaScript code in the right section.

Read More

What will happen when [50,100] is converted to Number in JavaScript?

Sai Subramanyam
Sai Subramanyam
Updated on 30-Jul-2019 157 Views

Use the Number() method in JavaScript to convert to Number. You can try to run the following code to learn how to convert [50, 100] to Number in JavaScript − Example Live Demo Convert [50,100] to Number var myVal = [50,100]; document.write("Number: " + Number(myVal));

Read More

How to set all the border left properties in one declaration with JavaScript?

Sai Subramanyam
Sai Subramanyam
Updated on 30-Jul-2019 138 Views

To set all the border left properties in a single declaration, use the borderLeft property. You can try to run the following code to learn how to set the border left properties − Example Live Demo #box { border: thick solid gray; width: 300px; height: 200px } Demo Text Change left border function display() { document.getElementById("box").style.borderLeft = "thick solid #000000"; }

Read More

How to set the width of an element's border with JavaScript?

Sai Subramanyam
Sai Subramanyam
Updated on 30-Jul-2019 1K+ Views

To set the width of an element’s border in JavaScript, use the borderWidth property. Set the width using this property. You can try to run the following code to learn how to set the width of an element’s border − Example Live Demo #box { border: thick solid gray; width: 300px; height: 200px } Demo Text Change border width function display() { document.getElementById("box").style.borderWidth = "thin"; }

Read More

How to set outline color with JavaScript?

Sai Subramanyam
Sai Subramanyam
Updated on 30-Jul-2019 560 Views

To set outline color, use the outlineColor property in JavaScript. You can try to run the following code to learn how to implement outlineColor property − Example Live Demo #box { border: 2px solid red; } Demo Content Change outline color function display() { document.getElementById("box").style.outlineColor = "#FF5733"; document.getElementById("box").style.outline = "2px solid"; }

Read More

How to set the order of the flexible item, relative to the rest with JavaScript?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 163 Views

To set the order of the flexible item, relative to the rest of JavaScript, use the order property. You can try to run the following code to implement order property − Example Live Demo #box { border: 1px solid #000000; width: 420px; height: 150px; display: flex; } #box div { height: 80px; width: 80px; } DIV1 DIV2 DIV3 Set function display() { document.getElementById("myID1").style.order = "3"; document.getElementById("myID2").style.order = "1"; document.getElementById("myID3").style.order = "2"; }

Read More

What is JavaScript garbage collection?

Vrundesha Joshi
Vrundesha Joshi
Updated on 30-Jul-2019 397 Views

JavaScript automatically allocates memory, while a variable is declared. Garbage collection finds memory no longer used by the application and releases it since it is of no use. Garbage collector uses algorithms like Mark-and-sweep algorithm, to find the memory no longer used.This algorithm is used to free memory when an object is unreachable. The garbage collector identifies the objects, which are reachable or unreachable. These unreachable objects get the treatment from the automatic garbage collector.The Reference-Counting Garbage Collection is also used for garbage collection in JavaScript. The object will get automatically garbage collected if there are no references to it. ...

Read More

How to offset an outline and draw it beyond the border edge with JavaScript?

Sai Subramanyam
Sai Subramanyam
Updated on 30-Jul-2019 248 Views

To offset an outline, use the outlineOffsetproperty. It allows you to draw the outline beyond the border edge. You can try to run the following code to offset an outline and draw it beyond the border edge with JavaScript. Example Live Demo #box { width: 450px; background-color: orange; ...

Read More
Showing 5321–5330 of 5,338 articles
Advertisements