Front End Technology Articles - Page 543 of 860

What is the use of Math.imul( ) Function in JavaScript?

vineeth.mariserla
Updated on 31-Jul-2019 13:44:55

177 Views

Math.imul( )Unlike other multiplying functions, the Math.imul() function returns the result of the C-like 32-bit multiplication of the two parameters. Its application is very high in projects like Emscripten. syntaxvar product = Math.imul(a, b);This method takes two numbers and gives out their multiplication value.Example-1In the following example, two normal integers were given as parameters to the method Math.Imul() and the obtained result is displayed as shown in the output.Live Demo document.write(Math.imul(3, 4)); document.write(""); document.write(Math.imul(-3, 4)); Output12 -12Example-2In the following example, c-like 32-bit values were given as parameters to ... Read More

How to find the cube root of a number in JavaScript?

Lokesh Yadav
Updated on 08-Dec-2022 08:16:58

3K+ Views

In this article we are going to discuss how find the cube root of a number with the help of suitable examples in JavaScript. Using Math object in JavaScript any kind of operation can be done. Math.cbrt(), Math.pow() are the methods especially used to find the cube root of a number and also we can achieve it by using ** operator. It takes a number as a parameter and returns its cube root. To find the cube root of a number in JavaScript, there are three possible ways. The way to do it is by using cbrt() method, second way ... Read More

How to convert a date object's content into json in JavaScript?

Manisha Patil
Updated on 04-Aug-2022 10:21:22

1K+ Views

The contents of the specified date object are converted into a string using the date.toJSON() function. Applying date() constructor, the date object is generated. Dates describe a particular moment in time. The value of the Date object is described by a string that is returned by the toJSON() function (using toISOString()). In general, this function is programmed to automatically meaningfully serialise Date objects during JSON serialisation. The DateObj is a valid Date object produced by the Date() constructor function, and its data has been transformed into a string. Here are some additional codes for the procedure mentioned below in the ... Read More

What is the importance of Symbol.isConcatSpreadable in JavaScript?

vineeth.mariserla
Updated on 31-Jul-2019 09:21:18

226 Views

Symbol.isConcatSpreadableThis well-known symbol is used to configure if an object should be flattened to its array elements when using the Array.prototype.concat() method. If it is false then there is no flattening of the array takes place. By default, the Symbol.IsConcatSpreadable is true. Therefore until and unless it is not declared explicitly flattening of the array can't be avoided.Without SymbolExampleIn the following example, the symbol Symbol.IsConcatSpreadable was doesn't stated explicitly. So by default, the array was flattened as shown in the output. var arr1 = ['mango', 'apple', 'guava']; var arr2 = ['cashew', 'pista', 'bhadham']; ... Read More

HTML DOM Location replace() method

AmitDiwan
Updated on 30-Jul-2019 22:30:26

220 Views

The HTML DOM Location replace() method is used for rendering a new document replacing the current document. It also removes the current document URL from document history disabling navigation to old document using ‘back’ button.SyntaxFollowing is the syntax −location.replace(URLString)ExampleLet us see an example for Location replace() property − Live Demo Location replace()    form {       width:70%;       margin: 0 auto;    text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } ... Read More

HTML DOM Location reload() method

AmitDiwan
Updated on 30-Jul-2019 22:30:26

305 Views

The HTML DOM Location reload() method is used for re – rendering the current document. It provides the same functionality as the reload button in the browser.SyntaxFollowing is the syntax −location.reload(forceGetParameter)ParametersHere, “forceGetParameter” can be the following −forceGetParameterDetailstrueIt defines that current document is reloaded from server.falseIt defines that current document is reloaded from browser cache.ExampleLet us see an example for Location reload() property − Live Demo Location reload()    form {       width:70%;       margin: 0 auto;    text-align: center;    }    * {       padding: 2px;       margin:5px;   ... Read More

HTML DOM Location protocol Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

120 Views

The Location protocol property returns/sets a string corresponding to the protocol used for a URL. Protocol can be set to ‘file:’, ‘http:’, ‘https:’, etc..SyntaxFollowing is the syntax −Returning value of the protocol propertylocation.protocolValue of the protocol property setlocation.protocol = protocolStringExampleLet us see an example for Location protocol property − Live Demo Location protocol    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } ... Read More

HTML DOM Location port Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

120 Views

The Location port property returns/sets the port number (if specified) for a URL. Port number might not get displayed if not explicitly specified.SyntaxFollowing is the syntax −Returning value of the port propertylocation.portValue of the port property setlocation.port = portNumberExampleLet us see an example for Location port property − Live Demo Location port    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } ... Read More

HTML DOM Location pathname Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

130 Views

The Location pathname property returns/sets the string corresponding to the URL pathname.SyntaxFollowing is the syntax −Returning value of the pathname propertylocation.pathnameValue of the href property setlocation.pathname = pathOfHostExampleLet us see an example for Location pathname property − Live Demo Location pathname    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } Location-pathname Current URL:    var divDisplay = document.getElementById("divDisplay");    var urlSelect = document.getElementById("urlSelect");    function getpathname(){       divDisplay.textContent = 'URL pathname: '+location.pathname;    } OutputThis will produce the following output −Before clicking ‘Get pathname’ button −After clicking ‘Get pathname’ button −

HTML DOM Location origin Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

123 Views

The Location origin property returns the string corresponding to the URL’s protocol, hostname, host port number (if specified).SyntaxFollowing is the syntax −Returning value of the origin propertylocation.originExampleLet us see an example for Location origin property − Live Demo Location origin    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } Location-origin Current URL:    var divDisplay = document.getElementById("divDisplay");    var urlSelect = document.getElementById("urlSelect");    function getorigin(){       divDisplay.textContent = 'URL Origin: '+location.origin;    } OutputThis will produce the following output −Before clicking ‘Get origin’ button −After clicking ‘Get origin’ button −

Advertisements