Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Javascript 201

Do you want me to continue this?


  • Total voters
    18

eivl

Local Hero
Xy$
0.00
So what is the deal with this JavaScript i hear people talking about.. Well.. since i am a terrible writer i will with the help of the internet compose my thoughts, not in my own words but in my own way.

I will need to reserve a few posts so i can explain more as i go.. hope that is ok.

If you hang around the JavaScript world long enough you will find standard ways of doing Object Oriented Programming. It looks like this.
JavaScript:
function MyClass() {
    ...
}

MyClass.prototype.method = function() {
    ...
}
And this is how you would do inheritance
JavaScript:
function MySubClass() {
    MyClass.call(this);
    ...
}
MySubClass.prototype = Object.create(MyClass.prototype);
MySubClass.prototype.constructor = MySubClass;

MySubClass.prototype.method = function() {
    MyClass.prototype.method.call(this);
    ...
}
So why this? why this mess? and how does it work?

Object Fundamentals
You have a few JavaScript types.

Primitive Types
Code:
Undefined: undefined
Null: null
Boolean: true
String: "foo"
Number: 3.14159
Object: { bar: "baz" }
Special Objects
Code:
Function: function qwe() {...}
Array: [ "answer", 42]
RegExp: /piyo/
functions, arrays and regexp are in fact objects.

What are objects?

Object are a set of name / value pairs or key/value pairs

The name can be anything as long as it is a string and each string can be assosiated with any value; Those value can be of any type, meaning any Primitive types or any object type.

Why so special?
Main difference is that Primitives are passed as value, while objects are passed as reference.
Lets look at an example of this.

JavaScript:
var number1, number2;

number1 =  3.14159;
number2 = number1; // => numer2 is now 3.14159

number2 = 42; // => number2 is now 42, number 1 is unchanged
Lets look at an example of an object.
Remember that i said that objects are stored as references.
JavaScript:
var object1, object2

object1 = {
    a: 3.14159
};

object2 = object1; // => object2s value is now 3.14159

object2.a = 42; // => now both objects have the same value
One more thing before we are done with the basics.

JavaScript:
var myObject = {
    a:  "foo",
    b:  "bar",
    c:  "baz"
};

myObject.x; // => undefined

myObject.c = undefined;

// the value c does not get removed just because you set its value to undefined, you will have to use the delete command.

delete myObject.c;
But the distinction between a deleted value and an actual undefined value is not that important.

Functions & Methods
I told you earlier that a function was an object. When you create it JavaScript creates an object with 3 properties, name, length and prototype

JavaScript:
function myFunction(a,b) {
    return 42;
};
name : "myFunction"
length: 2 //The number of arguments
prototype: ... // I will have to go into detail about this later

Everything you can do with an object you can do to a function.
  • Assign properties
  • Assign them to different variables
JavaScript:
function myFunction(a,b) {
    return 42;
};

myFunction.foo = "bar";

var function2 = myFunction;

function2(); //=> 42
Method
If you put a function inside of an object, it is called a method; You can run a method like you would run any other function by typing Object.MethodName().
When you do this JavaScript will set the "this" keyword to the object that you have used.
So if you do: myObject.get(), "this" will be set to myObject.

JavaScript:
var myObject = {
    get: function myMethod() {
        return this.val;
    },
    val: 42
};

myObject.get(); //=> 42
When the method returns, the keyword "this" will be set to whatever value it had before.

The "this" keyword is JavaScripts biggest CATCHA!!!!
It depends in its entirety on the object and not where the function was defined.

JavaScript:
function myMethod() {
    return this.val;
}

var object1 = {
    get: myMethod,
    val: 42
};

var object2 = {
    get: myMethod,
    val: 3.14159
};

object1.get(); //=> 42
object2.get(); //=> 3.14159
myMethod(); // ???? you will never know for sure what it will return, if you use strict mode this will be undefined.
Even if you use strict mode you will still need to handle the undefined values, but they are easier to find.
If you want to force a value, you can use call, apply or bind, more on those later.

But as an example we can say
JavaScript:
myMethod.call(object1); //=> 42
You force the "this" keyword to object1 and when you then call the function val is set to 42.

Now with the basic of objects done, lets get deeper and talk about Prototypal Inheritance.

Prototypal Inheritance
You don't want to define your objects from scratch, that is a maintenance nightmare.
let me give you an example of this nightmare.
JavaScript:
//This is not correct
function fn() {
    return this.val;
}

var object1 = {
    get: fn,
    val: 42
};

var object2 = {
    get: fn,
    val: 3.14159
};

var object3 = {
    get: fn,
    val: 84
};
Code:
// fn() //
name: "fn"
length: 0
prototype: ...
////////////

// object1 //
get: fn()
val: 42
////////////

// object2 //
get: fn()
val: 3.14159
////////////

// object3 //
get: fn()
val: 84
////////////
This is the status of the code when done incorrectly. You have 3 get keys that points to 1 object (the function)

What would be a better way would to link these together and have them inhere common keys (in this example it is the "get: fn()" that repeats

So what we do to use prototypes is to create a single object and have other inhere from it

JavaScript:
var parent = {
    get: function fn() {
        return this.val;
    },
    val: 42
};
to inhere from the parent, or what is also called extend, you use the create method on the child object
You can also add values to the child, or extend it again with another child

JavaScript:
var child = Object.create(parent);
child.val = 3.14159;

var grandchild = Object.create(child);
Now it gets interesting, we now how a grandchild, child with val: 3.14159 and parent with get: fn(), val: 42
Code:
//parent//
get: fn()
val:42
----------
//child//
val:3.14159
-----------
//grandchild
-----------
I said earlier that all objects have prototype, even i have not written it, it has this key.
Now let us try to get some values from our new objects.

JavaScript:
parent.get(); // => 42
the object is parent, so this is set to parent, get is inside the parent object so it is run, and it points to a function called fn(). Inside an object this is called a method, so the fn method is run with this as the parent, it will return the value val, which in this case is 42.

this = parent object
get() -> fn() -> returns this.val -> val inside parent = 42

I hope this is clear, if not let me know, this is important to understand how this works.

Let us test how this will work with the child object.
JavaScript:
child.get(); //=> 3.14159
this is set to the child object, it will look for get inside child but will not find it. Then it looks at the prototype, it will go up the prototype chain and look at parent.
Here it finds get, it will then run this.val, and since "this" is set to the child object, it will find it there and return val: 3.14159

this = child object
no get() in child -> prototype -> get() -> fn() -> returns this.val -> val is inside child = 3.14159
Javascript will go as far as it can up the prototype chain to find a property;
So if we said

JavaScript:
grandchild.get(); //=> 3.14159
JavaScript will look for get on the grandchild, then on the child, then on the parent, run the fn() method, "this" is set to grandchild, this.val is not found, it will go up the prototype chain to child and there it fins val: 3.14159

JavaScript:
var parent = {
    get: function fn() {
        return this.val;
    },
    val: 42
};
var child = Object.create(parent);
child.val = 3.14159;

var grandchild = Object.create(child);

parent.get(); // => 42
child.get(); //=> 3.14159
grandchild.get(); //=> 3.14159
So, this prototype behaviour is how JavaScript works on a fundamental level.

I have no more room, have to use a different post. linke here : http://www.rpgmakermv.co/threads/javascript-201.616/#post-6889

Polymorphism & Method Overriding
Once you have objects in a prototype chain, you might find out you want your children to behave different from their parent even when the same method name is called. This is called Polymorphism (same name but different behavior) and in JavaScript this is quite easy to do. You just use the same property name but assign a different method.

JavaScript:
var answer = {
    get: function fn1() {
        return this.val;
    },
    val: 42
};

var firmAnswer = Object.create(answer);
firmAnswer.get = function fn2() {
    return this.val + "!!";
};

answer.get();  //=> 42
firmAnswer.get();  //=> "42!!"

This is just a simple example, but notice that both functions return this.val
Even though it is not a bad example, this is still duplicated logic and in a larger program this kind of code will get quickly difficult to maintain. So typically what we want to do is to call function1 from function2.
But this is not as easy as it might seem, you might want to write it like this.
JavaScript:
//This code is NOT CORRECT
//The part "return answer.get()" is wrong

var answer = {
  get: function fn1() {
    return this.val;
},
val: 42
};

var firmAnswer = Object.create(answer);
  firmAnswer.get = function fn2() {
    return answer.get() + "!!";
};

firmAnswer.val = 3.14159;
firmAnswer.get(); //=> "42!!" (what we want to have returned is [COLOR=#ff8000]3.14159!![/COLOR])
Before you read on, study the example above and try to see why this is wrong and hence why it returns the wrong answer.

The reason this happens is because when firmAnswer.get() is run, this is set to firmAnswer and it looks for the get property, it finds it and then run fn2(). fn2() in turn runs answer.get() and this is set to answer. It then looks for the get property, finds it and run fn1() and then return this.val. this is set to answer and val in answer = 42


So in order to make this work properly, we need to use the call function.

JavaScript:
var answer = {
  get: function fn1() {
    return this.val;
},
val: 42
};

var firmAnswer = Object.create(answer);
  firmAnswer.get = function fn2() {
    return answer.get.call(this) + "!!";
};

firmAnswer.val = 3.14159;
firmAnswer.get()  //=> "3.14159!!"
Take a minute and study this to see if you get why this will work.
When we call firmAnswer.get(), this is set to firmAnswer, it looks for get, finds it and run fn2(), and now it says answer.get.call(this), it sets this to the same as before, firmAnswer and then runs answer.get() right away, and in turn it then runs fn1() and then return this.val. Since this is set to firmAnswer, it will return "3.14159"


I hope this is clear, even though i use a lot of this, i have tried to separate the linguistic meaning of the word and the programming meaning of the word with colors.

Here is the next part : http://www.rpgmakermv.co/threads/javascript-201.616/#post-6923

Classes & Instantiation
You can organize your JavaScript objects in any way you'd like, but a really common way of organizing it is to separate your methods from your data.

JavaScript:
var answer = {
  get: function fn1() {
    return this.val;
},
val: 42
};

answer.get();  //=> 42
Let us organize this code so that we can reuse the function to return different answers.
We will put the function in a prototype and call it AnswerProtype and we will have multiple object extend the prototype to give special values. Let us write the prototype and then some answers to life, universe and everything and let us not forget, pie.

JavaScript:
var AnswerPrototype = {
  get: function fn1() {
    return this.val;
  }
};

var lifeAnswer = Object.create(AnswerPrototype);
lifeAnswer.val = 42
lifeAnswer.get(); //=> 42

var desertAnswer = Object.create(AnswerPrototype);
desertAnswer.val = 3.14159
desertAnswer.get();  //=> 3.14159
Let us extend this code with the firmAnswer and have it return a lucky number and a magic number.

JavaScript:
var AnswerPrototype = {
  get: function fn1() {
    return this.val;
  }
};

var lifeAnswer = Object.create(AnswerPrototype);
lifeAnswer.val = 42
lifeAnswer.get(); //=> 42

var desertAnswer = Object.create(AnswerPrototype);
desertAnswer.val = 3.14159
desertAnswer.get();  //=> 3.14159

var FirmAnswerPrototype = Object.create(AnswerPrototype);
FirmAnswerPrototype.get = function fn2() {
  return AnswerPrototype.get.call(this) + "!!";
};

var luckyAnswer = Object.create(FirmAnswerPrototype):
luckyAnswer.val = 7;
luckyAnswer.get(); //=> "7!!"

var magicAnswer = Object.create(FirmAnswerPrototype);
magicAnswer.val = 3;
magicAnswer.get(); //=> "3!!"
A prototype (AnswerPrototype and FirmAnswerPrototype) are called Classes and the objects that extends them are called instances (FirmAnswerPrototype would be a subclass by this definition because it extends another class).

Creating a class is called instantiation, and it consist of a two part process, first you create the object by extending the prototype and second you initialize its data.

The problem with the way we have done it in the last example is that we have a lot of duplicated logic, we assign only one value to each object, but in a large program initializing data is a complex process and secondly this way of coding violates encapsulation, one of the biggest corner stones in Object Oriented Programming. To solve this, we will use an initialization function and we will call it constructor.

JavaScript:
var AnswerPrototype = {
  constructor: function fn0(value) {
    this._val = value;
  },
  get: function fn1() {
    return this._val;
  }
};

var lifeAnswer = Object.create(AnswerPrototype);
lifeAnswer.constructor(42);
lifeAnswer.get(); //=> 42

var desertAnswer = Object.create(AnswerPrototype);
desertAnswer.constructor(3.14159);
desertAnswer.get();  //=> 3.14159

var FirmAnswerPrototype = Object.create(AnswerPrototype);
FirmAnswerPrototype.get = function fn2() {
  return AnswerPrototype.get.call(this) + "!!";
};

var luckyAnswer = Object.create(FirmAnswerPrototype):
luckyAnswer.constructor(7);
luckyAnswer.get(); //=> "7!!"

var magicAnswer = Object.create(FirmAnswerPrototype);
magicAnswer.constructor(3);
magicAnswer.get(); //=> "3!!"
Note that I have change val to _val, this is a JavaScript coding convention, it means that the property is private and that you should not change it. Nothing in JavaScript is enforcing you to not access or change it, but it is polite not to do anything with it.

This is more or less the complete view of prototypal inheritance and using this model you can do all of your programming :)

The Classical Model
In the last part we instantiated an object by created an object by running a constructor of some sort, that is so common that JavaScript has a special keyword just for that, it is called new
However, new is a little weird, it does not work like the way we have seen up in til now and that is what make the classical model different from the prototypal model.

Before we start i have to show you something strange about functions.

JavaScript:
function fn0() {
};
This creates an object with three properties, name, length and prototype.
name = "fn0"
length = 0 // no arguments
prototype = fn0.prototype

the prototype property points to a whole new Object with a constructor property that points back to the function you just created.

This means, whenever you create a function you create two objects, the function object and this prototype object that is just hanging out there.

This is very familiar from what we did before, with Answer() and AnswerPrototype

JavaScript:
function Answer() {
};

var AnswerPrototype = {
  constructor: function fn0() {
    this._val = 42;
  }
};
This means that the extra object is a prototype, basically a class. So every time you define a function in JavaScript you are actually defining a constructor that is associated with a little do nothing class.
Now of course not every function you define is meant to be a constructor, so the common convention in JavaScript is that if it is meant to be a constructor it starts with a capital letter.
If it is meant to be a normal function it starts with a lower case letter.

So, now that the weirdness is over, let us see how this works out by comparing the prototype model with the classical model.

JavaScript:
//Prototype model
var AnswerPrototype = {
  constructor: function fn0(value) {
    this._val = value;
  },
  get: function fn1() {
    return this._val;
  }
};

var lifeAnswer = Object.create(AnswerPrototype);
lifeAnswer.constructor(42);
lifeAnswer.get(); //=> 42

var desertAnswer = Object.create(AnswerPrototype);
desertAnswer.constructor(3.14159);
desertAnswer.get();  //=> 3.14159

JavaScript:
// Classical model

function Answer(value) {
  this._val = value;
}

Answer.prototype.get = function fn1() {
  return this._val;
};

var lifeAnswer = new Answer(42);
lifeAnswer.get(); //=> 42

var desertAnswer = new Answer(3.14159);
desertAnswer.get();  //=> 3.14159
So in simple as i can put it, you use the already created prototype object to construct and initialize the data.
It is a little bit difficult when it comes to sub classes, so let us continue and add the firmAnswer sub class we looked at earlier.

JavaScript:
function Answer(value) {
  this._val = value;
}

Answer.prototype.get = function fn1() {
  return this._val;
};

var lifeAnswer = new Answer(42);
lifeAnswer.get(); //=> 42

var desertAnswer = new Answer(3.14159);
desertAnswer.get();  //=> 3.14159

// This is where we left off in the previous example

function FirmAnswer(value) {
  Answer.call(this, value);
} // JavaScript will now create a new protoype object, but we need to extend a different class, so we can not use this prototype as a constructor, we will instead make a new prototype object and point it to the Answer.prototype object, the extra unused object will be collected by the garbage collector since nothing is now pointing at it

FirmAnswer.prototype = Object.create(Answer.prototype);
FirmAnswer.prototype.constructor = FirmAnswer; //Since the other object with the original constructor has been removed by the garbage collector, we need to make a new constructor property and point it back to FirmAnswer.

FirmAnswer.prototype.get = function fn2() {
    return Answer.prototype.get.call(this) + "!!";
};

var luckyAnswer = new FirmAnswer(7);
luckyAnswer.get(); //=> "7!!"

var magicAnswer = new FirmAnswer(3);
magicAnswer.get(); //=> "3!!"
Creating a constructor in FirmAnswer.prototype is not required, but to be consistent we will recreate it.

Here is a side by side comparison of the prototypal and the classical model.



Next part here : http://www.rpgmakermv.co/threads/javascript-201.616/#post-6946

instanceof
It is often a good thing to know which class was used to instantiate an object. Javascript has a keyword instanceof
The way this work is that it looks at a prototype of a constructor and compares it to the object.

JavaScript:
function Answer(value) {
  this._val = value;
}

Answer.prototype.get = function fn1() {
  return this._val;
};

function FirmAnswer(value) {
  Answer.call(this, value);
}

FirmAnswer.prototype = Object.create(Answer.prototype);
FirmAnswer.prototype.constructor = FirmAnswer;

FirmAnswer.prototype.get = function fn2 () {
    return Answer.prototype.get.call(this) + "!!";
};

var lifeAnswer = new Answer(42);
var luckyAnswer = new FirmAnswer(7);

lifeAnswer instanceof Answer; //=> true
// First it looks at Answer prototype (this is the Answer.prototype object)
//Then it looks at the lifeAnswer prototype (this is the Answer.prototype object)
// since this is the same object, it returns true

lifeAnswer instanceof FirmAnswer; //=> false
// First it looks at FirmAnswer prototype (this is the FirmAnswer.prototype object)
//Then it looks at the lifeAnswer prototype (this is the Answer.prototype object)[/SIZE]
// since this is not the same object, it returns false
There are exceptions to this instanceof rules, it has to do with how certain objects will traverse up the prototype chain, but i don't want to make it more confusing by writing myself in a corner.

This is everything you need to know to understand how
Inheritance work in JavaScript

There is some changes in the newest version of Ecma Script 6, one is that you can use class definition like other object oriented languages uses.

JavaScript:
class Answer {
  constructor(value) {
    this._val = value;
  }
  get() {
    return this._val;
  }
}

var lifeAnswer = new Answer(42);
lifeAnswer.get();  //=> 42

var dessertAnswer = new Answer(3.14159);
dessertAnswer.get();  //=> 3.14159

class FirmAnswer extends Answer {
  constructor(value) {
    super(value);
  }
  get() {
    return super() + "!!";
    }
};

var luckyAnswer = new FirmAnswer(7);
luckyAnswer.get(); //=> "7!!"

var magicAnswer = new FirmAnswer(3);
magicAnswer.get();  //=> "3!!"
Study this at your own leisure.

This is it for now, there are a lot more, but this is the basis of Object Oriented JavaScript. There are plenty more to cover, getter and setters, static variables, how bind and apply works, but this is the start.

I use the classical model, works well in my IDE and support instanceof, i also "use strict"; mode, since i always want to have this be defined.

http://jshint.com/
http://www.jslint.com/

Two websites i recommend, bookmark them ;)

I am also try to go over to the ES6 class syntax, but until browser fully support it i am reluctant (ES6 in whole)


Hope this will be useful to someone ;)

 
Last edited by a moderator:

LTN Games

Master Mind
Resource Team
Xy$
0.01
I would love to see more of this as well, it's very helpful considering I need to find a balance between being a moderator and learning to javascript, and what better way than to learn while moderating :) Do you plan on doing a lot of this ?
 

LTN Games

Master Mind
Resource Team
Xy$
0.01
I am 20% done at this moment, give or take. when i am done with this, and if it is understandable, you should have the tools to understand what a script does by reading it.
I'm going to pin this thread, I believe it's going to be one of the most useful threads in this topic for a little while :)

And later i might do more related to MV, this is just pure JavaScript and how to understand what is going on.
I'm fine with what you're doing here, MV will be easier if people will follow along with this thread and learn from it. The way your explaining things is great, I cant wait for more.
 
I'm currently going over intermediate JavaScript concepts and just got to inheritance for my library job (coding JS webmap applications); man, it can be a pain in the butt to mark all the prototype information. If you're ever looking for an editor for wording things, feel free to bounce ideas off of me. Love what you've done so far.
 

eivl

Local Hero
Xy$
0.00
If you're ever looking for an editor for wording things, feel free to bounce ideas off of me. Love what you've done so far.
Well thanks! =) *blush*
I am planning a revised explanation of prototypes, maybe i should have someone make a video about it.
 

eivl

Local Hero
Xy$
0.00
Object Oriented Programming is far better to learn as a concept in stead of a feature to one language. Python, Java and JavaScript are languages i know well and all of them uses OOP. If you write Python or Java or JavaScript in any other way then Object Oriented, you are doing it wrong, it will work just fine, might be a nightmare to update anything, but it will work.
 

TheGoof

Knight
Xy$
0.00
I honestly so far hate JS more than Ruby, Ruby felt like a cake walk compared to this mess.
I thought it would be better, but i'm so damn lost with it.
Everything i try does not work, it returns errors every effing time...
No matter what i try...
Ruby made sense to me, things i tried worked.

JS just... ugh... i wanna ... well i wanna slam my head against a wall... a hard wall made of steel.. over and over until i feel better.
I can't get this stupid software to rather than play a VictoryMe, i try and tell it to look for the theme and play it as a Bgm in the Bgm folder.. it refuses.. it worked fine in ruby, but JS is so damn retarded it does not get what i'm telling it, or it's stubborn...
What happen to viewports?
Ruby had viewports, JS does not... Ruby had Z layers for windows, JS does not.

I can't even figure out how to tell the damn battle status window to stop effing moving left and right and just sit stationary!
I can't tell windows to properly overlap on screen.. instead they do this.. cutting thing.. like they're all on the same damn layer.
And everything i try refuses to work...

JS is a big damn mess... and i wish they had just used an even more advanced version of Ruby or something..
Ruby just feels more friendly and simple.. JS feels complex and annoying.. like an old nag you wanna take out into the fields behind the barn and blast several slugs into its skull.
 

TheGoof

Knight
Xy$
0.00
It's not code... it's edits to what is there.
Which worked fine in Ace... but not in MV.
I guess i need to find videos on youtube... i don't learn very well by reading.
I learn better by .. i guess being taught like having someone talking and making examples as they talk... basically a class 1 on 1 with a teacher.
I feel like i'm gonna be back to begging others to do things for me like i used to do... and it's driving me to tears...
What's worse is this makes MV feel like a waste of money and like i should go back to Ace...
And as for what i edit, i'm bad about undoing what does not work, so i have nothing to post.
 

TheGoof

Knight
Xy$
0.00
Yeah but what i meant is..
I mentioned youtube cause i can fallow a video more easily.
I fallowed this one rather easily and found it funny at the same time.
 

eivl

Local Hero
Xy$
0.00
from Wikipedia:

Ruby is:
Paradigm multi-paradigm: object-oriented, imperative,functional, reflective

JavaScript is:
Paradigm Multi-paradigm: scripting,object-oriented (prototype-based), imperative,functional[1]

The small differences in these languages makes it so important for me to explain how prototypes work.
[doublepost=1446209010,1446208840][/doublepost]
Yeah but what i meant is..
I mentioned youtube cause i can fallow a video more easily.
I fallowed this one rather easily and found it funny at the same time.
Wow, that video was great! =)
 

TheGoof

Knight
Xy$
0.00
It's not mine, but it's one of those few times i was able to fallow something and get it.
I gotta find more JS lessons on youtube...
I just wish i could find some SPECIFIC to RMMV.
 

eivl

Local Hero
Xy$
0.00
JavaScript:
Array(16).join("wat" -1) + " Batman!"
I laughed so hard my boss came to see what happened. ;)
[doublepost=1446209426,1446209286][/doublepost]
It's not mine, but it's one of those few times i was able to fallow something and get it.
I gotta find more JS lessons on youtube...
I just wish i could find some SPECIFIC to RMMV.
If you want lessons over skype let me know! I would happily let you or anyone else join a screencast while i try to code something that i have no idea how to do as well. =)

Like the keyboard re-mapper plugin i am going to write and have no idea if my "in the head" solution will actually work!
 

TheGoof

Knight
Xy$
0.00
It would have to wait until after the 8th... that's when my data resets... i'm stuck on satellite for internet.. and it's rather limited... and my monthly 10 gigs a month is almost out, if it's not already.
I keep hoping and praying that Verizon steps up and brings fiber to where i live... i been hearing they're supposed to... i hope so.
 

TheGoof

Knight
Xy$
0.00
Well, i DID read this.
http://coursesweb.net/javascript/introduction
And about to read more.
It's only called Javascript for marketing reasons, otherwise it may as well be called LiveScript.... as it has nothing to do with Java, it just has a similar name.
Shame they can't change the name now, to make newcomers less confused.
At this point it's causing more harm than good to have the word java in javascript.
 

David FoxFire

Adventurer
Xy$
0.00
Object Oriented Programming is far better to learn as a concept in stead of a feature to one language. Python, Java and JavaScript are languages i know well and all of them uses OOP. If you write Python or Java or JavaScript in any other way then Object Oriented, you are doing it wrong, it will work just fine, might be a nightmare to update anything, but it will work.
I learned Javascript in a more plain vanilla format, which is more suited for HTML pages. Usually short function()s that do what an HTML tag cannot. There was one class in college that demanded a C++ program in OOP and, since that was the first time I've ever heard of it, I didn't do very well. (Even switched majors because of it). I only wished there was a class that teaches how to do OOP properly back then.
 
Top