AmitDiwan has Published 10744 Articles

Short Circuit Assignment in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Jul-2020 08:10:28

214 Views

Following is the code to implement short circuit assignment in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result,    .sample {       font-size: 20px;       font-weight: 500;   ... Read More

Short-circuit evaluation in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Jul-2020 08:08:40

1K+ Views

Short circuit evaluation basically works with the && and || logical operators. The expressions are evaluated left to right.For && operator − Short circuit evaluation with &&(AND) logical operator means if the first expression evaluates to false then whole expression will be false and the rest of the expressions will ... Read More

Rounding and truncating numbers in JavaScript.

AmitDiwan

AmitDiwan

Updated on 18-Jul-2020 08:06:32

4K+ Views

There are two functions in JavaScript for rounding and truncating numbers: Math.round() and Math.trunc() respectively −Math.round() − = It rounds the decimal number to the nearest integer value.Math.trunc() − = It simply removes the fractional part of the decimal number and converts it to a whole number.Following is the code ... Read More

How to parse array of objects inside another object using maps or forEach?

AmitDiwan

AmitDiwan

Updated on 18-Jul-2020 08:05:09

141 Views

Following is the code to parse array of objects inside another object using maps or forEach −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       ... Read More

Does JavaScript support block scope?

AmitDiwan

AmitDiwan

Updated on 18-Jul-2020 08:03:27

227 Views

JavaScript supports block scope only for variables that were declared using let or const keyword. Variables declared using var support function scope but not block scope.Following is the code for displaying block scope in JavaScript −Example Live Demo Document    body {       font-family: ... Read More

Parsing array of objects inside an object using maps or forEach using JavaScript?

AmitDiwan

AmitDiwan

Updated on 18-Jul-2020 08:01:40

771 Views

Following is the code to parse array of objects inside an object using maps or forEach using JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;   ... Read More

The new operator in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Jul-2020 08:01:26

407 Views

The new operator is used for creating a user-defined object type instance of one of the builtin object types that has a constructor function.Following is the code for new operator in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, ... Read More

Referring JavaScript function from within itself

AmitDiwan

AmitDiwan

Updated on 18-Jul-2020 07:59:43

141 Views

Following is the code to refer JavaScript function from within itself −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       ... Read More

Binding an object's method to a click handler in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Jul-2020 07:58:14

242 Views

Following is the code for binding an object’s method to a click handler in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: ... Read More

Can we share a method between JavaScript objects in an array?

AmitDiwan

AmitDiwan

Updated on 18-Jul-2020 07:58:02

140 Views

Following is the code to share a method between objects in an array −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;   ... Read More

Advertisements