What is JavaScript

JavaScript is a programming language that have application in web developing and is responsible for logical functioning of the websites. It allows for manipulation of parts of the website in logical way. JavaScript is scripting language working on the side of web browsers, and differently to backhand programing languages it is describing working of the websites within user interface without entering in server side. JavaScript is nowadays one of the most often used programing language easy for application in HTML documents and is cooperating with CSS style sheets. In JavaScript we can manipulate HTML documents using classes and id's. We have here many methods of control the HTML documents, using events of mouse, keyboard, loading, resizing and many other. Despite the fact that dynamically developing web designing already have newer methods of programing for web, JavaScript is still popular among web developers. JavaScript can create content on HTML document only dynamically. It is not providing any changes in the structure of HTML code. From the level of JavaScript one can change styles of the documents or create new styles, however mostly recommended for creating styles is CSS, and using JavaScript for styling is troublesome. JavaScript was created by Brendan Eich, american hacker and programmer. Javascript can be applicated as a separated document or directly in HTML file in script section. If JavaScript script is done separately, HTML document should have link to the script, which has to be found in the same folder. If we want to add script link placed inside the HTML document to external JavaScript file, it should be placed most often on the end of HTML text, right before the body closing tag. The reason why it should be at the end of HTML document is proper working of entire document due to execution of required parts of the document before running the very script.




In programming based on JavaScript we have a lot of functions not allowed in HTML, or CSS code. Building the logically working interface is intelligence engaging process based on knowledge about functioning of JavaScript code with interaction with HTML elements. Working in JavaScript programing environment means working with many variables, objects, functions, loops ot conditions like if...than statements. Writing JavaScript code there are certain generally accepted principles like case sensitive writing of code, JavaScript is case sensitive language. There is style of writing the code called camel case. This mean for instance that first letter of statement or variables should be written lowercase letter and each visible and logically separated word in statement should be started uppercased letter. For instance statement "getElementsByClassName" should be not written like this "getelementsbyclassname" although logically means the same.


JavaScript can switch styling of HTML elements. Here one can use "toggle" function.


In the above example is applicated event sensitive function "addEventListener" and in this example it is event "click" by computer mouse indicated. After clicking on the text it will change to color red, according class ".change-color" after second click this text will return to color blue like in ".example" class.

We can also use here arrow function "( ) => { }", and this code will be also correct and will be working well.


Arrow function is simplification of code and is making faster writing code.

In JavaScript we can also create HTML content. Here the program is event driven,


  but we can also use "for" loop to obtain at once several iteration of some text.



Result

In above code we should declare in "for" loop a variable and in this case this is variable "i", we cannot applicate alone variable "i" without word "let" unless we have declared it first. We have three word of declaration - let, var or const. The difference between those declaration ways is relying on the way we want use the declared variable later. If we want to make declaration of variable which won't be changed in code, will be constant we should apply word const. If we predict that the variable will be changed in code we should apply word "let".


Above program is prompting "Some text" in one second steps. It is using setInterval() function that is allowing for describing the time of certain operation performed on during acting of the program.



Comments

Popular posts from this blog

CSS3