Google Apps Script JavaScript 2020 Update - V8 Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so some interesting news apparently appscript engine was just updated if I go to my script editor for a second here you'll see that now we have chrome v8 powered so I'm gonna go ahead and enable this so let me just rename this so if you don't already know JavaScript this is probably gonna be confusing but otherwise let's check out what's being done right so it says pretty much most of the stuff we can do in nodejs we should be able to do here now don't get too excited though you're probably not gonna be able to import packages and this type of stuff so I just want to test what type of things we could do so that means now with our current new engine we should be able to use Const and we don't really have to do semicolons anymore so that should be fine and I should be able to do something like this and then do equals 2x plus y and we also get a nicer console.log now instead of the logger log we used to use and I'll show you why that's nicer but for right now I'm gonna test this so I'm gonna do probably separate videos to explain you differences between all these different declarations so we used to use var for all of this if you already know this this video will be more interesting for you for everybody else I'm gonna be doing different videos covering this different topics here I'm just gonna test to see what features we can actually use out of newer ACMA script so let's go ahead and run this and check out the log so one thing I've noticed logs are taking longer time now hopefully that will be a temporary thing so there it is we get a three so now we can use consulate var all of that works we should be able to now use arrow functions so for exam let's say I declare an array so if I go back here now I was trying to map through that array I would do a rade map and usually I would do something like function and pass what I call row usually there but it doesn't matter a variable and then return our plus concatenates - 0 so I'll assign it to a new variable here and again I'm gonna be struggling with this semicolon no semicolon I don't really need this but I tend to do them anyway so let's just do another console log and console.log that new array so that should show you the difference of console lock now what I'm gonna see is that with this new console log it will actually show me what a variable types are at least show me the difference between like having strings and numbers which you couldn't see in the logs before see this is what it returns and it returns this little apostrophes now indicating that this is string and if you have a number you're not gonna get those so now I don't really have to use this function thing now we can use arrow functions so I should be able to do something like this and this should run as well again this whole delayed thing it's annoying there it is it's the same result so it works with the single liner stuff we could also skip that and that should also run which is gonna give me the same thing we even it wouldn't have to do this parentheses I guess so for some of this map stuff and filter I guess that may simplify the syntax a lot although if you're starting with this now it can be really confusing because there's like 70 different ways of doing the same thing but it works arrow functions apparently work just fine I would be surprised if they didn't what I'm more interested in if we can create like classes and things like that so let me just try to create something really quick so I'm going to create a class person didn't highlight this at all which is kind of interesting so let's create a constructor and in this constructor we'll pass a couple of variables and then assign it to object I guess so there we go no this should be named I'm a little worried about this whole thing so I'm gonna save it because there's no highlighting at all so let's see if this works let's try to go to our code and create a new person we're gonna pass a name and age something like this if this works if we go dot name let's consult lock that so let me just run this again this function on top to see if the class works because it didn't give me any highlighting it also didn't give me any errors let's go check it out so it returned Linda which means even though there's no highlighting for this that actually worked let me move this to a different script I'm gonna cut this out of here file new script move this in here save this save this alright so let's try to create method also tried to use a gator let's see if that works again you don't really need this semicolons but I keep doing them let's try this to see if this works so I'm gonna go back and try to use this hello method first so this instead of name now if we do hello like this it's a method call that let's see what we get so that worked so the matter to work let's use the get her out of here so I called it get aged which means we should be able to call it like this so if I run this it should get me the age if this works doesn't seem that way let's try this one more time I'm just gonna check this get aged return this let's just run this one more time all right so now it seems like it works maybe I didn't save something before but that works so I'm able to do this as well what else do we have in classes that are interesting maybe create a child class out of this so this should have all the stuff from this so let's just go try to create this thing so if I go here and change this person to our new class let's see if that works sorry Linda so run this yeah we're good no not sure why we're not logging this a writing run this again seems to have some weird things going on with it for now so now it works anyways so that works so we can extend our classes if we want to which is nice let's also see if we can create like a static method here so if I do something like let's see if it accepts static Matt hoods here so I'm gonna copy this and try to run this here so that means we should be able to take our person class and run this right away let's just console.log this to see what happens three this four so now I'm missing this log but it does seem to work for this one let's try this again yeah now it works that's so weird but anyways this works so we can actually use static methods to so we don't have to really create object out of this we can just run it directly on the class that's interesting so yeah it seems like we have full functionality for classes as far as I can tell let's see what else is interesting that we should check I'm gonna leave this function alone for a second let's just create a new one let me switch this to this function forget so let's check if we can do deconstructing here so if I do something like let X Y this has to go in this brackets and Z equals so this lets console.log the Z so basically what should happen X should be a Y should be B and this should be all of these in an array so let's see if that works it appears that it does if I change this to let's say 22 and run this I really hope this whole the lighting is temporary thing but anyway see I got CD and 22 now is not in coats because that's a number so just for the sake of doing the whole thing let's also just log out this too okay a B and we have the rest of the array so one of the things I'm curious about is if we can create generator functions so let me do this in here save this this should be here I guess it helps if you spelled things right it's just annoying that it's not highlighting any of this stuff hopefully they'll be updating this interface so it does some highlighting so far it doesn't seem to complain about this let's go and try to use this function generate so I'm gonna go here and do this and now if we call next on this so we should be able to do this and if I cancel log that a 1 that should get us 1 which is the first thing out of that oh so there it is so value one down false so basically there is more things to come out of here which means we should be able now to run next on that and get the next result and there should be three one for didn't do the last one I assume that's again something but the logging interface so I should just run this again there it is 1 4 and 55 so if we run it one more time it should be done so let me just do this one more time here a 4 and a 4 run this thing and then we have undefined and done true okay so surprising generators work too I'm curious if we can use async functions as well I'm not gonna be testing every possible thing here but most things that I think that might not be supported so if I do an async function I'm gonna call this let's just return something out of this see what happens so if this works we should be able to use the dot den notation with this let's go and test this out you go here and do and if we call that and do dot then on that then that should bring us this return let me change this from 1 to 333 so that means here we can accept that parameter and we can do an arrow function here and console.log that D which should at that point B that 333 so let's just go and run this function really quickly again no errors so I'm surprised even on that yep it worked we should be able to also just probably do this let's try that that should produce the same results that part worked I mean it doesn't lock some of this out which is kind of weird but it works so async functions apparently work as well I'm going to assume that require or import is not gonna work because of their environment but let's just give this a shot so I'm just gonna create a script file and call this so now let's go to our code and try to do no way this is gonna work I guess that should be the same folder or something let's try this okay so saving it didn't give me any airs but that doesn't surprise me because this kind of like a function so far so now assuming that this works it should not give me an error when I run at least let's check it out okay so require is not defined yeah that's what I thought I think the only other thing I want to try right now is to check default parameters for functions so if we create a function here and pass a couple of arguments here and then return x times y now if we go here and do this we should be able to just go here and do this and that should give us one so let's check okay so this is all getting confusing let me just erase all of this so one that's good which means now if we go here and do something like this that should do 12 because now it's not going to use the fault there it is and last let's use some back takes for Strings so now instead of using apostrophes I'm gonna use that back tic thing which is next to that one keyboard key and put our very total here so now this total should be just words and this total should be this total that comes out of here and then we should be able to do something like this let's output that text yep that worked out just fine so a long story short now we're using v8 as an engine and you can go ahead and use it right away thanks for watching please subscribe and I'll see you next one
Info
Channel: Learn Google Spreadsheets
Views: 12,470
Rating: undefined out of 5
Keywords: Google, Apps Script, JavaScript, V8
Id: 1S_v-SUfjJg
Channel Id: undefined
Length: 20min 30sec (1230 seconds)
Published: Mon Feb 17 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.