Mkotla has Published 100 Articles

Why in JavaScript, “if ('0' == false)” is equal to false whereas it gives true in “if(0)” statement?

mkotla

mkotla

Updated on 16-Jun-2020 13:28:37

1K+ Views

Let’s see the conditions one by one − if(‘0’ == false)It follows the following rule −If Type(y) is Boolean, return the result of the comparison x == ToNumber(y)The == does type coercion. This means an explicit type conversion is requested to match the type of the two operands. The left side ... Read More

Why does void in JavaScript require an argument?

mkotla

mkotla

Updated on 16-Jun-2020 13:16:19

89 Views

The void operator is used to evaluate the given expression. After that, it returns undefined. It obtains the undefined primitive value, using void(0) i.e. 0 as an argument.The void(0) can be used with hyperlinks to obtain the undefined primitive value, ExampleLive Demo           Understanding JavaScript ... Read More

How to customize the position of an alert box using JavaScript?

mkotla

mkotla

Updated on 16-Jun-2020 12:45:56

2K+ Views

To customize the position of an alert box, use the CSS “top” and “left” properties. We have a custom alert box, which we’ve created using jQuery and styled with CSS.ExampleYou can try to run the following code to customize the position of an alert box −Live Demo     ... Read More

How to set multiple cookies in JavaScript?

mkotla

mkotla

Updated on 16-Jun-2020 11:59:40

3K+ Views

With JavaScript, to set more than one cookie, set document.cookie more than once using the; separator.ExampleYou can try to run the following code to set multiple cookies −Live Demo                 var num=1;       function addCookie() {       ... Read More

How to write a global error handler in JavaScript?

mkotla

mkotla

Updated on 16-Jun-2020 11:40:30

2K+ Views

The following global error handler will show how to catch unhandled exception −Example                    window.onerror = function(errMsg, url, line, column, error) {             var result = !column ? '' : 'column: ' + column;             result += !error;             document.write("Error= " + errMsg + "url= " + url + "line= " + line + result);             var suppressErrorAlert = true;             return suppressErrorAlert;          };          setTimeout(function() {             eval("{");          }, 500)          

What is a default constructor in JavaScript?

mkotla

mkotla

Updated on 12-Jun-2020 14:04:17

648 Views

If a constructor method is not added, then a default constructor should be used. A default constructor is created when nothing is defined.SyntaxHere’s the syntax −constructor() {}The syntax for derived class −constructor(...args) {    super(...args); }

Style options for the HTML5 Date picker

mkotla

mkotla

Updated on 02-Jun-2020 09:20:33

1K+ Views

The date picker in HTML5 basically works very similar to how the JavaScript Libraries did, when we focus on the field a calendar will pop out, and then we can navigate through the months and years to select the date.Therefore, if you want the date input to use more spacing ... Read More

What is the basic syntax to access Python Dictionary Elements?

mkotla

mkotla

Updated on 05-Mar-2020 10:02:01

131 Views

You can access a dictionary value to a variable in Python using the access operator []. examplemy_dict = {    'foo': 42, 'bar': 12.5 } new_var = my_dict['foo'] print(new_var)OutputThis will give the output −42You can also access the value using the get method on the dictionary. examplemy_dict = {    'foo': 42, ... Read More

HTML5 check if audio is playing

mkotla

mkotla

Updated on 04-Mar-2020 04:59:44

3K+ Views

Use the following to check if audio is playing −functionisPlaying(audelem) {    return!audelem.paused; }The above code can be used to check ifaudio is playing or not. The audio tag has a paused property.The paused property returns whether the audio/video is paused.You can also toggle −functiontogglePause() {    if(newAudio.paused && newAudio.currentTime > 0 ... Read More

Execute a script after the document is printed in HTML?

mkotla

mkotla

Updated on 03-Mar-2020 12:31:48

143 Views

Use the HTML onafterprint attribute to execute a script after the document is printed or it is printing.ExampleYou can try to run the following code to implement onafterprint attribute −                    function display() {             alert("Success!");          }          

Previous 1 ... 3 4 5 6 7 ... 10 Next
Advertisements