How to use a line break in array values in JavaScript?

radhakrishna
Published on 23-Jan-2018 14:55:45
To add a line break in array values for every occurrence of ~, first split the array. After splitting, add a line break i.e. <br> for each occurrence of ~.For example, This is demo text 1!~This is demo text 2!~~This is demo text 3!This will add line breaks like the ... Read More

How to use height and width attributes in HTML?

Rishi Rathor
Published on 22-Jan-2018 12:13:06
The height and width attribute in HTML is used to specify the height and width of the element. The values are set in px i.e. pixels.The height and width attribute is used in the following HTML elements:S. NoElementsAttributeAttribute1<canvas> elementheightwidth2<embed> elementheightwidth3<iframe> elementheightwidth4<img> elementheightwidth5<input> elementheightwidth6<object> elementheightwidth7<video> elementheightwidthTo add an image in an ... Read More

What is lexical this in JavaScript?

Sreemaha
Published on 23-Jan-2018 14:42:11
Fat arrow function solves the issue of lexical binding “this”. It gets the context of “this “and you can fulfill the same purpose since fast arrow does not have its own this. Fat arrow function as the name suggests helps in decreasing line of code. The syntax => shows fat ... Read More

How to use arrow functions used as methods in JavaScript?

Swarali Sree
Published on 23-Jan-2018 14:15:26
Fat arrow function as the name suggests helps in decreasing line of code. The syntax => shows fat arrow. This also avoids you to write the keyword “function” repeatedly. Arrow functions are generally used for a non-method function. Let’s see how to use arrow functions used as methods:ExampleYou can try ... Read More

What is a fat arrow function in JavaScript?

Samual Sam
Published on 23-Jan-2018 14:08:31
Fat arrow function as the name suggests helps in decreasing line of code. The syntax => shows fat arrow. This also avoids you to write the keyword “function” repeatedly.Here’s the syntax:argument => expressionUse the following for more than one argument:(argument1 [, argument2]) => expressionLet’s compare a function with and without ... Read More

How do nested functions work in Python?

varma
Published on 23-Jan-2018 14:39:21
To learn about nested function, refer the following code. In the code, you can see Inner functions can access variables from the enclosing scope, which is the local variable.def mulFunc(num1):    def mul(num2):       return num1 * num2    return mul res = mulFunc(15) // The following prints ... Read More

What is the usage of yield keyword in JavaScript?

usharani
Published on 23-Jan-2018 14:37:46
The yield keyword is used in JavaScript to pause and resume a generator function. The value of the expression is returned to the generator's caller.Here’s the syntax, where “exp” is the expression and the optional value is returned by “val”, which is passed to the generator's next() method.[val] = yield ... Read More

What are immediate functions in JavaScript?

varun
Published on 23-Jan-2018 14:34:56
The immediate function executes as soon as it is defined. To understand the role of immediate function, let’s see the difference between a function and an immediate function −Here’s immediate function −(function() {    var str = "display"; }()); function display() {    // this returns undefined    alert(str); }Here’s ... Read More

How to preserve variables in a JavaScript closure function?

Prabhas
Published on 23-Jan-2018 14:32:36
To preserve variables in a JavaScript closure function, do not set it to empty. Right now, the following is set to empty object each time it is called webLinks = {};Use the following code to retain the value:var webLink = function (containerId) {    var link1 = "http://www.qries.com",    link2 = ... Read More

What are Rest parameters in JavaScript?

seetha
Published on 23-Jan-2018 14:29:08
restES6 brought rest parameter to ease the work of developers. For arguments objects, rest parameters are indicated by three dots … and precedes a parameter.With this, set indefinite number of arguments as an array, which areArray instances.ExampleLet’s see the following code snippet:<html>    <body>       <script>     ... Read More
Advertisements