what is this "javascript" they speak of?
Its a type of coding language, most websites are made with it i'm guessing, and I have been dying to learn it!
The big three languages for web dev:
- HTML (HyperText Markup Language; like nouns)
a. E.g. buttons, paragraphs, text fields, images, and more - CSS (Cascading Style Sheets; like adjectives)
a. E.g. color, spacing, size, cursors, and more - JS (JavaScript; like verbs)
a. E.g. looping, moving, editing, event handling, and more
You can use JS to change the CSS of an HTML element!
whoa. cool
Do you mean Inspect Element?
The Element Inspector is a developer tool that allows the viewing and editing of HTML elements.
Hey,its hard.You have to remember which properties are ele.style.foo(eg font-color=fontColor) and which are ele.foo(eg width)and class is a reserved word(so you use className intead of class)
But i think ES6 properties no longer cant be reserved.
In es5:
var foo={}
foo["if"]="bar"
In es6:
var foo={if:"bar"}
foo.if="baz"
yes i meant that
ctrl-u
JS!! That's the shortcut I was trying to remember!
how to make stuff m o v e with JavaScript?
should I copy+paste the whole Snap! forums code onto here to analyze it better? or should I not?
function i made:
function alert(alertText){
window.alert(alertText);
}
alert("woah, this is cool")
console.log("Donald Trump is Donald duck, when you turn his head upside down")
<meta name="discourse_theme_ids" content="2">
idk, copy+paste is a friend.
Does this work for movement?
this.left(12)
The alert function was already made. The default object is window
, so before you made that function, alert
is the same as window.alert
. I just tested it in the console: if you define function alert
, it changes the window's alert function, so it just keeps calling itself recursively until the call stack gets too big.
What is a call stack?
A stack is a data structure that puts data in and takes data out from the same end.
A call stack is a stack that keeps track of function calls.
Another function call puts a frame in the stack, then removes it when the function ends (maybe from a return
statement)