Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts
Original source
48 responses to “Beginner JavaScript Tutorial – 31 – join and pop”
pop removes the last element….? why simply do not delete the last element from the array?
i underststand what pop does now but WHY would i use it? i.e. no point in learning it if cant use it. Maybe next video will explain?
if you guys want to remove first array, you can use shift() function with same way.
can any one tell me why the variable name As "name" does not accept in java script.for example if i write a code
var name= new Array("Ash","Ashish","abhinav","kumar");
var string = name.join();
document.write(string);
this code will not generate desire output but if i will use the variable such as "people" rather than "name" then it will generate output.
i.e
var people = new Array("Ash","Ashish","abhinav","kumar");
var string = people.join();
document.write(string);
output:Ash,Ashish,abhinav,kumar
you like ham but ham is also unhealthy doctor say that
thank you bucky roberts
Wow great explaination bucky!!!! Does anyone knows how to take input from user in javascript not forms.
Avatar Will Vanilla Fight
go ahead and write the name of your shtring
if anyone can help me with this.
what pop();
is used for why do i create an array then use pop to remove the last one ???
why to convert an array into a string?
pretty cool huh 😛
http://www.gcflearnfree.org/typing/
don't talk about undefined.
STRIENG
Pretty much cool 😀
More methods here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Methods_Index
oh because of i forgot " " when giving value to movies.join( – ) , my code couldn't get printed . took so long to realize that .
You can also do the opposite to convert a string to array. Example:
var string1 = "tuna – ham – bacon";
var groceryList = string1.split(" – ");
now groceryList is an Array object with "tuna", "ham", "bacon"
🙂
is this series of tutorial enough ?
When he said P- O – P I had to say "HOLD IT DOWN MOMMA I LOVE YOU"
why put <br/> in quotation marks?
When you said join method adds commas,i document.write without the join method and it still had commas.
Just to add to this, the pop() function will return the removed value of the array.
var arr = new Array("apple", "banana");
var string1 = arr.pop();
The variable string1 has the value "banana".
555 likes o.o illuminati
join() method is same as document.write(movies);
Dude, You Broke 1st rule !!
hay can you help me???
i have a problem in the "for" loop
he does the loop just one time
<html>
<head>
</head>
<body>
<script type="text/javascript">
var num = new Array (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
for (x=0;x<20;X++)
{
var string1 = num.join(" – ");
document.write (string1);
num.pop();
document.write (num[19]);
}
</script>
</body>
</html>
ok does this make any diff with concat??
I used this code to see what was happening:
var movies = new Array ("Wolf of Wall Street", "Sin City", "The Godfather", "Apocalypse Now", "Das Experiment");
var stop = movies.length;//stop used to control when for loop terminates – in this case it is 5 as there are 5 elements in array
//This loop prints each element of array and then removes the end element – it loops 5 times
for (count = 0; count < stop; count++)
{
var string1 = movies.join(" – ");//adds all elements of array to string and separates with comma by default or you can put separator in brackets
document.write(string1 + "<br/>");//prints all the elements of the array
movies.pop();//removes 1 element of array
}
Do you ever show how to implement all these wonderful lessons into actual real world uses?
Why would someone want to use POP method if they don't want the data to be in an Array ?
Roger Kun::::::::::
6 Years and you know Java??? AND C++
Im only 6 and i know html, java,javascript,c++, and all those fucking languages out there including chinese.
It is simple.
I am 14 and already know html, css and php.
but if you don't know thath, don't watch this. XD
in case anyone doesn't know… "Being able to understand technology and control it today, is as fundamental as being able to read and write"… ugh F-YOU treehouse!!! Why advertise on a channel that has hundreds of excellent, free programming videos!?
this is the computer crap you do not want to watch! or else you're gonna be a mindfucked website designer!
if u made it this far . .. hats off !! u got real ambition dude 🙂
this shows how to fuck your self
Thanks for the tutorial !
I am 12 years old and what is this
Try this: document.write(movies);
The output will still be the same!
Could we use the pop command to remove "Justin Bieber" from the music array?
Begginers should already know what does LIFO means if they want to fully undestand the function of the pop method….
Separated by commas.
The array gets printed out just by typing "document.write(array)" without using join. At least for me it did.
What's the 1 for in (2,1)?
Can you pass in a number the pop() method to remove an element in the middle? For example, pop(2) to remove Vanilla Sky?