Java-Script-Class
introduction to javascript javascript is a dynamic and weakly typed interpreted programming language and compiled on runtime it is built to be executed in a browser with engine v8 (chrome) and and spidermonkey (firefox) which does the parsing and interpretation of code, javascript was later extracted and became node.js and can be executed on any machine, it can be used to build web backends and can interact with the operationg machine
Java is OBJECT ORIENTED AND STRONGLY TYPED Javascript is flexible and weakly typed
we were thought how to follow the course and make use of the materials and participate in the assignments
how to Add javascript
- <script src="fileLocation"></script>
- <script> alert("this is javascript") </script>
DECLARATION OF VARIABLES AND CONSTANT
variables are data containers whr the values can be changed variables are declared with the "LET" keyword, eg let userName = 'DAVE'
constant are also data containers where the vaules can'ts be changed constants are declared using the "const" keywords, eg const circle = 360
functions are reffered to as code on demand because the code doesnt get to run immediately, it runs when it is been called and it could be the first code but the last action on the app. it is defined with FOR DECLARATION: "function homeButtonClick(onclick){ alert("this is a fnction"); }" FOR CALLING A FUNCTION: functionName(parameters);
this section educates on writting a code that would be easy to read by someone else,by the appropriate use of whitespaces eg: WITHOUT WHITESPACE: function anExample(noWhiteSpace){ alert("didnt make use of whitespace")}
WITH WHITESPACE: function aExample(with whitespace) { alert("made use of whitespace") } SYNTAX when you make a mistake or forgot to add an component or a step while coding
RETURN KEYWORD: used to return a value and no action can be taken after the return keyword has been declared
parsing of a string to a number uisng the parseInt/ parseFloat keyword better still '+ +' can be used instead