Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
Finally, the course compares how code is written in several different languages, the libraries and frameworks that have grown around them, and the reasons to choose each one.
Let's say var today = new Date. The variable today would now contain today's date, not as a string but as a Date object. We can create new Date objects with a particular data. And actually because this object definition stores time, we could even create a new Date object with a year, month, day, hours, minutes, seconds in it. Now you might think, but so what? Well, of course the great thing is these are objects. They have properties, and they have methods. We can start using the name of one of these variables like today or y2k and calling parts of it.
We can say today.getMonth and it would return 0-11 for the month. today.getFullYear returns the normal year. .getDate, .getDay, .getHours, and so on. So there is a lot of behavior that the Date object can give us to start pulling apart dates. And not only that, but they have the flip side of the get method, which are our set methods. We can create a new Date object and then use it to say .setMonth or .setFullYear or .setDay.
What you might do is first say create a variable called x and I am setting this to 200.6. And I would like to round this number. This is the way I do it. I would create a new variable called y and create it by calling Math.round, passing in that variable x. That would give me 201. It would round it up. So we often just use the Math object directly. Say we create several variables. One is 200, one is 10000, one is 4, but at some point in my program, I don't know which one is which and which one is higher.
I can create a new variable called biggest, which will be whatever gets returned from calling Math.max and passing in those three numbers. In fact, Math.max will take as many numbers as you want to pass into it and always return the biggest one. If we have a .max, it would be nice if we had a .min. And not surprisingly, we do. So the Math object is there and has many built-in methods and properties for giving us Pi, calculating random numbers, rounding things up or down, calculating logarithms, sines and cosines and so on.
There are currently no FAQs about Foundations of Programming: Fundamentals.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.