How to concatenate several strings in JavaScript?

Ramu Prasad
Published on 23-Jan-2018 12:04:23
To concatenate several string, use “Array.join()” method. Here, we will concat the following strings:John Amit SachinExampleYou can try to run the following code to concat several stringsLive Demo<html>    <body>       <script>          var arr = ['Amit', 'John', 'Sachin'];          document.write(arr.join(', ')); ... Read More

How to use typeof with arguments in JavaScript?

Sravani S
Published on 23-Jan-2018 11:57:45
Arguments object is the arguments passed to a function. It is a variable accessible for all functions. Let’s say two arguments are passed to a function, then you can access them like the following:arguments[0] arguments[1]In the same way, you can use a type of with arguments in JavaScript. Firstly, let’s ... Read More

How to know if an object has an attribute in Python?

Rajendra Dharmkar
Published on 24-Jan-2018 10:52:00
We can use hasattr() function to find if a python object obj has a certain attribute or property. hasattr(obj, 'attribute'):The convention in python is that, if the property is likely to be there, simply call it and catch it with a try/except block. If the property is likely to not be ... Read More

What is arguments object in JavaScript?

Priya Pallavi
Published on 23-Jan-2018 11:51:32
Arguments object in JavaScript is an object, which represents the arguments to the function executing. Its syntax has two arguments:[function.]arguments[p]ExampleYou can try to run the following code to learn what are arguments object in JavaScriptLive Demo<html>    <body>       <script>          function functionArgument(val1, val2, val3) ... Read More

How can I save HTML locally with JavaScript?

Nikitha N
Published on 23-Jan-2018 11:46:39
To save HTML locally with JavaScript, create an HTML file and save the following code in it. The code is for cookies in JavaScript −<!DOCTYPE html> <html>    <body>       <p id="visits"></p>       <script>          var visits = parseInt(document.cookie.split("=")[1]);         ... Read More

How to show a foreach loop using a flow chart in JavaScript?’

Srinivas Gorla
Published on 23-Jan-2018 11:43:36
The following shows foreach loop using flow chart:

How to use OR condition in a JavaScript IF statement?

Abhinanda Shri
Published on 23-Jan-2018 11:40:47
To use OR condition in JavaScript IF statement, use the || operator i.e Logical OR operator. If any of the two operands are non-zero, then the condition becomes true.Here’s how you can use the operator || in JavaScriptExampleLive Demo<html>    <body>       <script>          var ... Read More

What is the difference between for...of and for...in statements in JavaScript?

Ankitha Reddy
Published on 23-Jan-2018 11:37:39
for…in loopThe “for...in” loop is used to loop through an object's properties.Here’s the syntax −Syntaxfor (variablename in object) { statement or block to execute }You can try to run the following example to implement ‘for-in’ loop. It prints the web browser’s Navigator objectExampleLive Demo<html> <body> <script> var aProperty; document.write("Navigator Object ... Read More

What does a +function() { } notation do in JavaScript?

V Jyothi
Published on 23-Jan-2018 11:00:08
The +function() {} notation is primarily used to force the parser to treat whatever follows the + as an expression. This is used for functions that are invoked immediately, for example, +function() { alert("Demo!"); }();However, + before a function is one of the symbol. You can add other options also ... Read More

How do you get a timestamp in JavaScript?

Abhinaya
Published on 23-Jan-2018 11:29:25
To get the timestamp in Java Script, you can try to run the following code. It returns the timestamp since 1970/01/01ExampleLive Demo<!DOCTYPE html> <html>    <body>       <script>          var timeStamp = Math.floor(Date.now() / 1000);          document.write("TimeStamp= "+timeStamp);       </script> ... Read More
Advertisements