Home Website & Development Fundamentals of JavaScript| Let's Make a Ride-on Functions of JS

Fundamentals of JavaScript| Let’s Make a Ride-on Functions of JS

If you know the basics of JavaScript Then you easily understand that fundamentals. First, you knew about what is the fundamentals of JavaScript and how you can use it?

What types of functions do you use in js?

Do you know about with the help of js do you validate your info of your client on web pages?

You can validate your client info with valid functions.

Can you imagine which type of data types and functions you can use to create a js?

Let’s start the journey of the Fundamentals of JavaScript.

Are you excited to learn about these fundamentals!!!

Learn with JavaScript Imagination

Now if we want to think more customers are visiting your website and use your services.

So, we can make our websites more interactive and easily understand to user.

Ready to take off the flight with js and learn how to make beautiful and interesting web pages.

Let’s go!!!

Master with JavaScript

Think of fundamentals that way, if a JS functions are your plane and you are the pilot of the plane means you create code.

I hope you know how to write the js and the syntax of js. But what we need to apply more interesting functions on js?

So, we can start it……

Well, its functions are connections and communicate with the web pages.

For example, functions are friends when we talk easily your problems like your web pages can easily understand what needs the client to your website.

Let’s start our journey for masters of JS

What’s in it you learn for me

  1. Variables of JS
  2. Events on JS
  3. Pop-up boxes of JS
  4. Functions of JS
  5. Loops and Repetition of JS
  6. Validate function of JS
  7. JavaScript vs HTML
  8. FAQ

What are Variables of JS?

variables of JavaScript

Here we can you only three

  • Var
  • Const
  • Let

JavaScript Variable is your Memory or containers to store or save your data values.

All the JS variables must be verifying with distinctive names.

Some rules of distinctive identifiers:

  • It can be considered letters, digits, _ and $
  • Start with a letter
  • It is case sensitive

We can learn how “var” variable use in JS

Var means a variable that is local to a function

Ex:

<script>

    if (true) {

              var msg = ‘hi buddy’;

      }

           alert(msg);

</script>

You can try this program on your own and understand how they show the message.

Let’s move on next “const” variable

It defines a constant variable that value does not change.

For ex:

<script>

  const msg = “hello”;

   msg = “bye”;

   alert(msg);

</script>

Here the above example if you can run then nothing to show anything. Because in const we declare hello then we change bye so console does not understand and they show empty display in run time.

So that’s why in const we can not change the value later.

Now we can learn “let” variable

It defines a variable is local to scope of the inner most side.

Ex:

<script>

      if (true) {

           let msg = ‘hi’;

  }

alert(msg);

</script>

Here let was used to show a message and it cannot pass through alert and if you can run your program then no alert would pop-up.

So that’s it on variables and hope you clear the how to use variables.

Events of JS

Process of event JavaScript

Events are “things” that happen to HTML.

When JS is used in the HTML page, JS can “react” on these particular events.

Some JS events include:

JS EVENT

Let’s try one program with the use of event

<html>

<body>

<p>Click the button to display the date. </p>

<button onclick=”displayDate ()”>Display the time?

</button>

<script>

function displayDate () {

  document. getElementById(“my”). innerHTML = Date ();

}

</script>

<p id=”my”></p>

</body>

</html>

Try this program own and understand -how the events work with JS.

Now we move on to the next topic….

Pop-up Boxes

Popup boxes of JS

Three different pop-up boxes JavaScript provides.

  1. Alert box
  2. Confirm box
  3. Prompt box

Alert box

  The alert box is used to inform the user.

Ex:

  alert (“wait for the second”);

Confirm box

   When the alert box is open you can click the “ok” button and confirm the certain action.

Ex:

    var a = confirm (“Are you sure?”);    

Prompt box

  The prompt box is used to receive a value from the user.

Ex:

   var data = prompt (“Enter your name”);

That’s it!!

Now you try all pop-up boxes in your way and apply to your website.

Functions

A function is a section of code that is separate from the main program. It is defined once but can be invoked many times.

Ex:

<html>

<body>

<script type = “type/javascript”>

  var a = multiCbyB (10, 20);

  document. write (“the result is” + a);

   function multiCbyB (c, b) {

          document. write (“c is” + c);

          document. write (“b is” + b);

          return c*b;

}

</script>

</body>

</html>

I hope do you understand and clear the concept of functions.

If you cannot remember all the function command then download the cheat sheet of JavaScript.

Loops and Repetition

function loop in JS

When programing that you need to repeat over a section of code several times. You may want to repeat a set of times, or break out of the loop when something happens.

JavaScript loop structure

For

Use when you know how many repetitions you want to do

Ex:

for (x=0; x<10; x++) {

    document. write (a[x]);

}

While

Loop through block of code while condition is true.

Ex:

   i = 10;

  while (i<=20) {

         document. write (x[i]);

          i++;

}

Do

Execute block at least once then repeat while condition is true.

Ex:

   i = 10;

   do {

           document. write (x[i]);

           i++;

} while (i<=20);

So, this is the loops we can use on your website to more iterative.

Validate the JS

validation  process form

Validate the form using JS

Ex:

<html>

<head>

<script>

function validateForm () {

  var x = document. forms [“Form”][“name”].value;

  if (x == “”) {

    alert (“Name must be filled out”);

    return false;

  }

}

</script>

</head>

<body>

<form name=”Form” action=”/action_page.php” onsubmit=”return validateForm ()” method=”post”>

  Name: <input type=”text” name=”name”>

  <input type=”submit” value=”Submit”>

</form>

</body>

</html>

Here your client data validate and action will generate on the PHP side which means storing the data on the backend side.

JavaScript vs HTML

JavaScript vs HTML
JSHTML
JS is a programming language used to create dynamic web pages.HTML is a standard markup language used to create static web pages.  
It adds interactive to web pages and make them look good and attractive.It defines the basic structure of the web and shows the look of the website.  
JS is a client-side scripting language which means every code is executed on a web browser.  HTML is rendered from the server-side language.
JS is not a cross-browser which means some functions may not work on the web browser.  HTML is a cross-browser which means works with all versions of the web browser.
JS manipulates the content to create dynamic web pages.    HTML page is static which means the content is not be changed.

Conclusion

Overall the above content is for all of the Fundamentals of JavaScript and also, learn the types of variable, events, popup-box, etc. Moreover, we can learn Advanced of JavaScript. So, you can easily understand the advanced concept of JS.

FAQ

1) JS variable is declaring with var and without var what is mean by that?

If you are declared variables with var then it is local and without var means always it is global.

2) Are JS variables case sensitive?

This means that the language keyword, variables, and any other name must always be typed with consistent upper letters. Means name and NAME will convey different meanings in JS.

3) Which looping structure is supported and which are not supported?

For, do-while and while are supported looping functions, and the for-each is not supported looping structure.

4) What was the original name of the JS?

The original name of the js is “LiveScript”.

5) What is the advantage of server-side scripting language?

It can reduce the burden on the server and easy to create and use.

RELATED ARTICLES

5 Best Laptops Under 60000 Suitable To Your Profession

Today we live in the era of the internet in which laptops and mobile phones play an important role. So if you...

5 Best Inverters to Buy This Year | How to Choose the Right Inverter

We all know inverters are useful for getting backup of electricity, but fewer people know about all features and types. If you...

Top Selling Best Budget Smartphones That You Can Buy This Year

Are you planning to buy a smartphone? Or Looking for a budget smartphones with the best features?  Almost everyone is stuck with...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

5 Best Laptops Under 60000 Suitable To Your Profession

Today we live in the era of the internet in which laptops and mobile phones play an important role. So if you...

5 Best Inverters to Buy This Year | How to Choose the Right Inverter

We all know inverters are useful for getting backup of electricity, but fewer people know about all features and types. If you...

Top Selling Best Budget Smartphones That You Can Buy This Year

Are you planning to buy a smartphone? Or Looking for a budget smartphones with the best features?  Almost everyone is stuck with...

Top 10 Network Marketing Companies in India | Future of MLM Business

Everybody knows about marketing that it is an essential part of a business. It is essential to promote our product to others...

Recent Comments