Front End Technology Articles

Page 589 of 652

How to add a number of months to a date using JavaScript?

Paul Richard
Paul Richard
Updated on 07-Jan-2020 806 Views

To add a number of months to a date, first get the month using getMonth() method and add a number of months.ExampleYou can try to run the following code to add a number of monthsLive Demo                    var d, e;          d = new Date();          document.write(d);          e = d.getMonth()+1;          document.write("Incremented month = "+e);          

Read More

How to determine if an argument is sent to the JavaScript function?

Krantik Chavan
Krantik Chavan
Updated on 07-Jan-2020 146 Views

To determine if an argument is sent to function, use “default” parameters.ExampleYou can try to run the following to implement itLive Demo                    function display(arg1 = 'Tutorials', arg2 = 'Learning') {             document.write(arg1 + ' ' +arg2+"");          }          display('Tutorials', 'Learning');          display('Tutorials');          display();          

Read More

How to use variable number of arguments to function in JavaScript?

Krantik Chavan
Krantik Chavan
Updated on 07-Jan-2020 692 Views

To use a variable number of arguments to function, use the arguments object.ExampleYou can try to run the following code to implement arguments to a function in JavaScriptLive Demo                    function functionArgument(val1, val2, val3)  {             var res = "";             res += "Expected Arguments: " + functionArgument.length;             res += "";             res += "Current Arguments : " + arguments.length;             res += "";             res += "Each argument = "             for (p = 0; p < arguments.length; p++) {                res += "";                res += functionArgument.arguments[p];                res += " ";             }             document.write(res);          }          functionArgument(20, 50, 80, "Demo Text!","Hello World", new Date())          

Read More

What is the JavaScript version of sleep()?

Alankritha Ammu
Alankritha Ammu
Updated on 07-Jan-2020 456 Views

The JavaScript version of sleep() is “await”. The await feature pauses the current aync function.ExampleYou can try to run the following code to implement sleep in JavaScriptLive Demo                    function setSleep(ms) {             return new Promise(resolve => setTimeout(resolve, ms));          }          async function Display() {             document.write('Wait for 5 seconds!');             await setSleep(5000);             document.write('After 5 seconds!');          }          Display();          

Read More

How to define functions inside a function body in JavaScript?

mkotla
mkotla
Updated on 07-Jan-2020 225 Views

To achieve what you want, use JavaScript Closures. A closure is a function, which uses the scope in which it was declared when invoked. It is not the scope in which it was invoked.ExampleLet’s take your example and this is how you can achieve your task. Here, innerDisplay() is a JavaScript closure.Var myFunction = (function () {    function display() {       // 5    };    function innerDisplay (a) {       if (/* some condition */ ) {          // 1          // 2          display();       }else {          // 3          // 4          display();       }    }    return innerDisplay; })();

Read More

Where are JavaScript variables stored?

Samual Sam
Samual Sam
Updated on 07-Jan-2020 2K+ Views

Like many other programming languages, JavaScript has variables. Variables can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container.JavaScript variables get stored in the memory of the browser process. The following ways can work for storing variables:The variables which you declare in your JavaScript code gets saved in the memory of the browser process.Cookies can also store variables, they are often saved on your hard disk;

Read More

Setting Line Height in CSS

AmitDiwan
AmitDiwan
Updated on 06-Jan-2020 80 Views

The height of a line can be defined by the CSS line-height property. It accepts only positive values.SyntaxThe syntax of CSS line-height property is as follows −Selector {    line-height: /*value*/ }ExampleThe following examples illustrate the CSS line-height property. Live Demo div * {    margin: 1.5em;    box-shadow: -13px -10px 10px 1px crimson; } #demo {    line-height: 60%; } p {    box-shadow: 13px -10px 10px 1px grey;    line-height: 50px; } Demo Heading This is demo text one. This is demo text two. This is demo text three. OutputThis ...

Read More

Controlling the Position of Table Caption using CSS

AmitDiwan
AmitDiwan
Updated on 06-Jan-2020 819 Views

The CSS caption-side property is used to vertically position the table caption box. It can take top and bottom as values. By default, table caption is placed at the top.SyntaxThe syntax of CSS list-style property is as follows−Selector {    caption-side: /*value*/ }ExampleThe following examples illustrate the CSS caption-side property. Live Demo table * {    border: ridge skyblue;    padding: 0.5rem; } table {    margin: 20px;    box-shadow: 0 0 6px 3px indianred;    empty-cells: show; } caption {    border-top-style: none;    caption-side: bottom;    border-color: darkkhaki;    border-radius: 50%; } ...

Read More

Cross Browser Solution for Image Marker in CSS

AmitDiwan
AmitDiwan
Updated on 06-Jan-2020 211 Views

In order to display an image marker properly in all browsers, a cross-browser solution is required. The text alignment after the image marker is sometimes distorted. To achieve a uniform output, we specify the image to be used as a marker as background and align it accordingly.ExampleThe following examples illustrate styling of lists − Live Demo ul{    list-style-type: none;    padding: 0px;    margin: 0px;    font-size: 1.5em; } ul li{    background-image: url("https://www.tutorialspoint.com/images/spring.png");    background-repeat: no-repeat;    background-position: 0px 5px;    padding-left: 24px; } Tutorials Java C# C C++ Spring Hibernate ...

Read More

CSS Background Properties

AmitDiwan
AmitDiwan
Updated on 06-Jan-2020 2K+ Views

CSS background properties help us style the background of elements. The CSS background property is a shorthand for specifying the background of an element. background-color, background-image, background-repeat, background-position, background-clip, background-size, background-origin and background-attachment together comprise the CSS background properties.SyntaxThe syntax of CSS background property is as follows−Selector {    background: /*value*/ }ExampleThe following examples illustrate CSS background property − Live Demo #main {    margin: auto;    width: 300px;    background-image: url("https://www.tutorialspoint.com/hadoop/images/hadoop-mini-logo.jpg");    background-repeat: no-repeat;    background-size: cover; } #im {    height: 200px;    width: 200px;    background-image: url("https://www.tutorialspoint.com/images/css.png");    background-repeat: no-repeat;    background-position: center; } ...

Read More
Showing 5881–5890 of 6,517 articles
« Prev 1 587 588 589 590 591 652 Next »
Advertisements