google+javascriptbanktwitter@js_bankfacebook@jsbankrss@jsbank






Some JavaScript Scripting Basics This free JavaScript tutorial shows you some basis JavaScript tips and tricks to develop your JavaScript applications, web applications better. JavaScript tips and tricks mentioned in this free JavaScript article are: JavaScript Functions, JavaScript Looping, JavaScript Variables, JavaScript Pre-Built Functions and JavaScript Operators, Comments.

Try more JavaScript lessons on jsB@nk as you want:
- Some Basic Tips and Tricks for Speeding Up JavaScript
- The basics of Javascript for beginners
- JavaScript Tutorial 1.1 - The Very Basics


Free iPage Web Hosting for First Year NOW



If you're still looking for a reliable web host provider with affordable rates, why you don't take a little of time to try iPage, only with $1.89/month, included $500+ Free Extra Credits for the payment of 24 months ($45)?

Over 1,000,000+ existisng customers can not be wrong, definitely you're not, too! More important, when you register the web hosting at iPage through our link, we're going to be happy for resending a full refund to you. That's awesome! You should try iPage web hosting for FREE now! And contact us for anything you need to know about iPage.
Try iPage for FREE First Year NOW

Javascript Variables

Variables are locations that you define you want to store information in. You use the keyword var to tell the browser you want to create a new place to store information and then assign that variable with a value. Ex. var myEmail = "[email protected]";

You can change the value of a variable at anytime, just by assigning it a new value with the equals sign. The name of your variable can contain any letter of number and it is considered good form to start the name with a lower case letter and then capitalize each word there after. Ex. thisIsANiceName

Variables created inside of functions are only accessible inside of the function in which they are declared. If you want to be able to access a variable anywhere in your Javascript program make sure that you declare it outside of a function. You should also never create two variables with the same name.

Unlike most programming languages, Javascript is what they call loosely typed. You see most languages require you to tell them what types of information you will assign to a variable. Is it a small number, a really big number, text, etc. Javascript doesn't care, except for a few instances. You can assign a number to a variable name and then text. Javascript will even convert text into a number and add it to another number, if at all possible. Ex:

var numberOne = 5; // Creates a variable named numberOne and assigns the value of 5 to it
var textTwo ="10″; // Creates a variable named textTwo and assigns the text string "10″ to it
document.writelin(numberOne + textTwo); // Would print 15 to the screen even though textTwo is technically text and not a number.

Variables that Must be Defined

Arrays

There are only two variable types that must be declared, the Array and Date data types. An array is a variable that can store multiple values. You create an array as such: var vehicles = new Array("car", "truck", "van");

The values of this array variable can now be accessed by specifying the number of the value stored in the array. The numbers are assigned from zero on up. For example:

  • The value of vehicles[0] is equal to car
  • The value of vehicles[1] is equal to truck
  • The value of vehicles[2] is equal to van

You can also add additional values to the array. For example to add "bicycle" to the array, you would type: vehicles[3] = "bicycles";

Dates

You define a date variable in the following ways:

  • var today = new Date(); // Will create a Date Variable and call the Date() function to assign the current time and date to it
  • var myBirthDay = new Date(1974, 12, 21); // Creates a Date variable and assigns my birthday to it

Javascript Pre-Built Functions & Operators

There are many pre-built functions and operators available to you with Javascript Scripting. To finish this article I'll go over a few of the most common operators for you:

  • + (Addition): Used to add numeric values or combine 2 strings of text
  • - (Subtraction): Used to subtract values
  • * (Multiply): Used to multiply values
  • / (Divide): Used to divide values
  • % (Modulus): Used to return the remainder of a division of two numbers. Ex. 15 % 7 = 1
  • ++ (Increment): Shorthand way to add one to a value.
  • - (Decrement): Shorthand way to subtract one from a value

You can also use a shorthand notation to add and then assign a value to a variable. Ex:

  • x += y: Adds x and y, then stores that value in the variable x
  • x -= y: Subtracts y from x, then stores that value in the variable x

In the looping section above we were performing comparisons. Here is a list of the ways you can compare information:

  • x == y: Tests whether x equals y
  • x < y: Tests whether x is less than y
  • x > y: Tests whether x is less than y
  • x <= y: Tests whether x is less than or equal to y
  • x >= y: Tests whether x is greater than or equal to y
  • x != y: Tests whether x is not equal to y
  • x= (y < 5) ? 10 : 15 : Shorthand way to test and then assign a value based on the test. This code tests if y<5, if the answer is TRUE then x is assigned the value of 10, if not x is assigned the value of 15

Finally, there are three operators that can be used to test further on how different values compare. These operators are referred to as logical operators and include the following:

  • if ( x < y && a > b ): && is used here to check if both comparisons are TRUE. If x < y is true AND a > b, then this comparison returns the answer TRUE. If either is not TRUE it returns the value FALSE.
  • if ( x < y || a > b ): || is used to see if just one comparison is TRUE. If one or the other or both comparisons are TRUE, then TRUE is returned, if both are untrue then FALSE is returned.
  • if (!x): This is the NOT operator. It is used to check if values are not equal to the variable it is being used on.

That's all Folks

Well that is it for now. In the next article I'll explain what objects are and how they are used in Javascript. As well I'll go into detail on how you use the Document Object Model (DOM) to jazz up your web pages.

If you have questions or comments leave them below.

Till next time...

AIVideo-App.com
Generate your business videos by AI with voice or just text

chatGPTaz.com
Talk to ChatGPT by your mother language

AppAIVideo
Your first FREE AI Video App

Deepfake Video
Deepfake AI Video Maker

Deepfake
Deepfake AI Video Maker

AI Deep Fake
Deepfake AI Video Maker

AIvidio
AI Video Mobile Solutions

AIvideos
AI Video Platform & Solutions

AIvedio
AI Video App Maker

Artificial General Intelligence
Ai and higher level Artificial General Intelligence (AGI)

Artificial General Intelligence
Ai and higher level Artificial General Intelligence (AGI)

Faceswap AI Online
Swap Faces Video, Photo & GIFs Instantly with Powerful AI Tools - Faceswap AI Online FREE

Faceswap AI Online
Swap Faces Video, Photo & GIFs Instantly with Powerful AI Tools - Faceswap AI Online FREE

Faceswap AI Online
Swap Faces Video, Photo & GIFs Instantly with Powerful AI Tools - Faceswap AI Online FREE

Powerful AI Presentation PPT Maker for FREE
Build an impressive presentation with our free online AI presentation app

Your next top AI Assistant
Claude AI, developed by Anthropic

Your next top AI Assistant
Claude AI, developed by Anthropic

Temu Free $500 for New Users
Claim Free Temu $500 Credit via Affiliate & Influencer Program

Free TikTok Ads Credit
Master TikTok Ads for Your Business Marketing

Dall-E-OpenAI.com
Generate creative images automatically with AI

chatGPT4.win
Talk to ChatGPT by your mother language

First AI Product from Elon Musk - Grok/UN.com
Speak to Grok AI Chatbot with Your Language

Tooly.win
Open tool hub for free to use by any one for every one with hundreds of tools

GateIO.gomymobi.com
Free Airdrops to Claim, Share Up to $150,000 per Project

iPhoneKer.com
Save up to 630$ when buy new iPhone 16

Buy Tesla Optimus Robot
Order Your Tesla Bot: Optimus Gen 2 Robot Today for less than $20k

JavaScript by day


Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web