How to create arrays in JavaScript?

Anjana
Published on 17-Jan-2018 11:59:01
To create an array in JavaScript, simply assign values −var animals = ["Dog", "Cat", "Tiger"];You can also use the new keyword to create arrays in JavaScript −var animals = new Array("Dog", "Cat", "Tiger");The Array parameter is a list of strings or integers. When you specify a single numeric parameter with ... Read More

What is the best way to concatenate strings in JavaScript?

Akshaya Akki
Published on 17-Jan-2018 11:56:14
The best and fastest way to concatenate strings in JavaScript is to use the + operator. You can also use the concat() method.ExampleYou can try to run the following code to concatenate strings in JavaScriptLive Demo<html>    <head>       <title>JavaScript Concatenation</title>    </head>    <body>     ... Read More

How do I replace a character at a particular index in JavaScript?

Manikanth Mani
Published on 17-Jan-2018 11:53:24
To replace a character at a particular index in JavaScript, you can try to run the following codeExampleLive Demo<html>    <head>       <title>JavaScript Boolean</title>    </head>    <body>       <script>          var str = "cric";          document.write("Original String: "+str); ... Read More

How to use a Boolean in JavaScript Constructors?

Alankritha Ammu
Published on 17-Jan-2018 11:45:51
To use Boolean in JavaScript constructors, use JavaScript boolean constructor() method. It returns a reference to the Boolean function that created the instance's prototype.ExampleYou can try to run the following code to learn how to use Booleans in ConstructorsLive Demo<html>    <head>       <title>JavaScript constructor() Method</title>    </head> ... Read More

How to generate Prime Numbers in JavaScript?

Ayyan
Published on 17-Jan-2018 11:43:48
To generate prime numbers in JavaScript, you can try to run the following codeExampleLive Demo<html>    <head>       <title>JavaScript Prime</title>    </head>    <body>       <script>          for (var limit = 1; limit <= 20; limit++) {           ... Read More

How to get the length of a string in JavaScript?

Anjana
Published on 17-Jan-2018 11:39:58
To get the length of a string in JavaScript, use the length property. The length property returns the number of characters in a string.ExampleYou can try to run the following code to learn how to get the length of a stringLive Demo<html>    <head>       <title>JavaScript String length ... Read More

Is there a Boolean Typed Array in JavaScript?

Akshaya Akki
Published on 17-Jan-2018 11:37:54
No, Boolean Typed Array does not exist. JavaScript supports the following typed arrays −Int8ArrayUint8ArrayUint8ClampedArrayInt16ArrayUint16ArrayInt32ArrayUint32ArrayFloat32ArrayFloat64ArrayAbove, you can see the typed arrays are only available for integers and floats various sizes.

How do I compare String and Boolean in JavaScript?

Manikanth Mani
Published on 17-Jan-2018 11:36:00
To compare string and Boolean in JavaScript, let us see the following examples. It returns true −false == "0"; //true true == "1"; //true false == ""; //trueThe followings returns false −false == "false"; //false true == "true"; //falseIn addition, try the following example too −var data = true; data ... Read More

What is an exclamation “!” operator in JavaScript?

Alankritha Ammu
Published on 17-Jan-2018 11:33:24
The exclamation operator is to perform negation on an expression.ExampleYou can try to run the following code to learn how to implement exclamation(!) operator in JavaScript −Live Demo<html>    <head>       <title>JavaScript Boolean</title>    </head>    <body>       <script>          var answer ... Read More

How to convert a Boolean to Integer in JavaScript?

Ayyan
Published on 17-Jan-2018 11:30:28
Yes, it is possible to convert Boolean to Integer in JavaScript, using the Ternary Operator.ExampleYou can try to run the following code to convert Boolean to Integer −Live Demo<html>    <head>       <title>JavaScript Boolean</title>    </head>    <body>       <script>          var ... Read More
Advertisements