Hey there!
Uh, I just wanna say that it's not exactly a tutorial that'll help you improve your forum or something like that. But, in this tutorial I'll explain JavaScript from 0 into 1001. I'll explain any methods and any facts about it. If you didn't understand please ask me and I'll answer you honestly. If there's any errors, grammar problems or something do not hesitate to notify me.
I'll update this tutorial every time I want to update
Welcome to my tutorial! Here I'll explain the very basic of JavaScript. The tutorial includes:
Alright, let's start!
I. Primitive Types
This is the common things you'll see inside scripts. Anyway. There are 5 primitive types inside JavaScript:
You'll see that 5 primitive types a lot in script, so don't misunderstood it!
II. Constant
Constant was a read-only variable. It's not really useful; but if you want a read-only variable then use this.
How to use it: [ic]const nameofconstant = valueofconstant;[/ic]
An example to it:
III. Variable
Variable.... you'll see this a lot in mostly scripts. Easy take a look.
A variable can contain anything you like. Functions, objects, numbers, strings, bools, anything. You can declare it with [ic]var[/ic], and you can make an empty variable as I show in my example above. You can even re-declare it. And remember that if you wanna re-declare you don't have to re-type the var, just type the name of the variable and you're good.
Variable can also contain another variable... sure, without the var tag.
The above code didn't work properly. If you type [ic]newVariable1[/ic] in the Console, it returns undefined. Simply because the location. The newVariable2 was created right after being declared, hence the undefined.
So, this is the fix:
That'd cover the gist of tutorial #1. If you have any questions, or you'd want to report any missing info, grammar errors, etc don't hesitate to contact me.
Thank you!
Uh, I just wanna say that it's not exactly a tutorial that'll help you improve your forum or something like that. But, in this tutorial I'll explain JavaScript from 0 into 1001. I'll explain any methods and any facts about it. If you didn't understand please ask me and I'll answer you honestly. If there's any errors, grammar problems or something do not hesitate to notify me.
I'll update this tutorial every time I want to update
Tutorial #1: Basic of JavaScript
(the very basic.. actually)Welcome to my tutorial! Here I'll explain the very basic of JavaScript. The tutorial includes:
- Primitive types,
- Constant,
- Variables.
Alright, let's start!
I. Primitive Types
This is the common things you'll see inside scripts. Anyway. There are 5 primitive types inside JavaScript:
- [ic]Number[/ic]: 99, 100, 9.99
- [ic]Boolean[/ic]: [ic]true[/ic] / [ic]false[/ic]. [ic]true[/ic] equals to 1, while [ic]false[/ic] equals to 0.
- [ic]String[/ic]: "Hello World" / 'Hello World' (must wrapped inside single quotes or double quotes)
- [ic]null[/ic]: intentional absence of any object value.
- [ic]undefined[/ic]: an undefined value.
You'll see that 5 primitive types a lot in script, so don't misunderstood it!
II. Constant
Constant was a read-only variable. It's not really useful; but if you want a read-only variable then use this.
How to use it: [ic]const nameofconstant = valueofconstant;[/ic]
An example to it:
- Code:
[panda=js]const numberOne = 1;
- Code:
[panda=js]const numberOne;
// SyntaxError
- Code:
[panda=js]const numberOne = "value of constant";
const numberOne = "new value!";
//TypeError
III. Variable
Variable.... you'll see this a lot in mostly scripts. Easy take a look.
- Code:
[panda=js]var newVariable;
A variable can contain anything you like. Functions, objects, numbers, strings, bools, anything. You can declare it with [ic]var[/ic], and you can make an empty variable as I show in my example above. You can even re-declare it. And remember that if you wanna re-declare you don't have to re-type the var, just type the name of the variable and you're good.
- Code:
[panda=js]var newVariable = "value of variable";
newVariable = "new value!"; // correct
var newVariable = "new value!"; // incorrect
Variable can also contain another variable... sure, without the var tag.
- Code:
[panda=js]var newVariable1 = newVariable2;
var newVariable2 = "Variable 1 or 2";
The above code didn't work properly. If you type [ic]newVariable1[/ic] in the Console, it returns undefined. Simply because the location. The newVariable2 was created right after being declared, hence the undefined.
So, this is the fix:
- Code:
[panda=js]var newVariable1 = "Variable 1";
var newVariable2 = newVariable1;
That'd cover the gist of tutorial #1. If you have any questions, or you'd want to report any missing info, grammar errors, etc don't hesitate to contact me.
Thank you!