Found 8895 Articles for Front End Technology

What are the various types of comments in JavaScript?

Prabhas
Updated on 12-Sep-2019 08:20:29

121 Views

Single Line commentThe following is a single line comment in JavaScript. Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript.// This is a comment. It is similar to comments in C++Multi-Line commentThe following is a multi-line comment in JavaScript./*    * This is a multiline comment in JavaScript    * It is very similar to comments in C Programming */

What are JavaScript basics?

seetha
Updated on 02-Jan-2020 09:54:00

223 Views

JavaScript basics include an overview of JavaScript. JavaScript is a dynamic computer programming language. It is lightweight and most commonly used as a part of web pages, whose implementations allow a client-side script to interact with the user and make dynamic pages. It is an interpreted programming language with object-oriented capabilities.VariablesLike 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.Scope of VariablesThe scope of a variable is the region of your program in which it is ... Read More

Is JavaScript a case sensitive language?

radhakrishna
Updated on 02-Jan-2020 09:51:50

3K+ Views

JavaScript is a case-sensitive language. This means that the language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.So the identifiers Time and TIME will convey different meanings in JavaScript.NOTE − Care should be taken while writing variable and function names in JavaScript.ExampleThe following example shows JavaScript is a case-sensitive language:           My favorite subject                       var subject, Subject;           subject = "Java";           Subject = "Maths";           document.getElementById("demo").innerHTML = subject;          

What does the leading semicolon in JavaScript libraries do?

mkotla
Updated on 30-Sep-2019 06:59:03

228 Views

A function in JavaScript looks like the following:(function(){...})()A library in JavaScript shows a function, which begins with a semicolon, for example:;(function ) { }The semicolon allows to safely concatenate several JS files into one. This is to serve it faster as one HTTP request.A leading semicolon can also be to protect from preceding code, which may have been improperly closed. A semicolon will definitely prevent this from happening.

How do I convert a float number to a whole number in JavaScript?

Shubham Vora
Updated on 20-Jul-2022 08:17:30

4K+ Views

In this tutorial, we will learn to convert a float number to a whole number in JavaScript. The whole number is the number that doesn’t contain the fractional part. For example, 5.22 is the float number containing the fractional part, and the whole number doesn’t contain a decimal part. So, our goal in this tutorial is to remove the fractional part from the number.We can have various methods to cut out the decimal part from the float number to make it whole, and some of them we have discussed here.Using the Math.trunc() and Math.round() MethodsUsing the parseInt() MethodUsing the Bitwise ... Read More

When should I use a semicolon after curly braces in JavaScript?

varma
Updated on 12-Sep-2019 08:04:37

308 Views

In JavaScript, Semicolons are optional. Simple statements in JavaScript are generally followed by a semicolon character, just as they are in C, C++, and Java. JavaScript, however, allows you to omit this semicolon if each of your statements is placed on a separate line. It is a good programming practice to use semicolons.In JavaScript, use a semi-colon after a statement. Let’s see an example of a variable assignment:var s = function() {    alert("Hello World!"); };However, semicolons aren’t necessary for the following function declarations:function() {    alert("Hello World!"); };

Do we need to use semicolons in JavaScript?

varun
Updated on 12-Sep-2019 08:05:42

125 Views

In JavaScript, Semicolons are optional. Simple statements in JavaScript are generally followed by a semicolon character, just as they are in C, C++, and Java. JavaScript, however, allows you to omit this semicolon if each of your statements is placed on a separate line. It is a good programming practice to use semicolons.For example, the following code could be written without semicolon.     But when formatted in a single line as follows, you must use semicolons −    

What Are Whitespace and Line Breaks in JavaScript?

usharani
Updated on 12-Sep-2019 08:07:03

1K+ Views

JavaScript ignores spaces, tabs, and newlines that appear in JavaScript programs. You can use spaces, tabs, and newlines freely in your program and you are free to format and indent your programs in a neat and consistent way that makes the code easy to read and understand.JavaScript ignores whitespaces. For example, the following are same:var employee = "Amit"; var employee="Amit";Line breaks in JavaScript:           Line-break in an alert box. Click below button.       Click    

How can I replace newlines with spaces in JavaScript?

Shubham Vora
Updated on 12-Jul-2022 14:15:16

4K+ Views

This tutorial teaches us to replace newlines with spaces in JavaScript. Often, programmers find unusual line breaks in the string, and the random line breaks look weird when we render them on the webpage using JavaScript.So, the solution is that programmers just need to remove the line breaks and join the string with the space or other characters. Here, we have different approaches to solving this problem, and we will use the regular expression with the replace() method to remove the unusual line breaks.Using the replace() MethodUsing the split() and join() MethodsUsing the replace() MethodIn this approach, we will use ... Read More

What is the difference between a method and a function?

seetha
Updated on 30-Sep-2019 06:57:27

6K+ Views

Method and a function are the same, with different terms. A method is a procedure or function in object-oriented programming.A function is a group of reusable code which can be called anywhere in your program. This eliminates the need for writing the same code again and again. It helps programmers in writing modular codes.The following is the syntax of a JavaScript function:     Here’s an example:    

Advertisements