Tagged Template Literals

  Рет қаралды 11,003

Steve Griffith - Prof3ssorSt3v3

Steve Griffith - Prof3ssorSt3v3

Күн бұрын

Template literal strings are great for embedding (interpolating) variables and expressions inside JavaScript strings.
They also include a feature called tagged template literals that let you create a function which will give you granular control over all the strings and expressions inside the template string.
Code from video: gist.github.co...
Array reduce method video: • JavaScript Array reduc...

Пікірлер: 44
@theartist8835
@theartist8835 4 жыл бұрын
i don't know why you and dcode has far less subscribers although you both are among the best ! Thank you for the effort you put into this. keep up the amazing work!
@techlover1219
@techlover1219 4 жыл бұрын
I love your content. Your content has improved me a lot♥️♥️
@phanCAbe
@phanCAbe 4 жыл бұрын
Hey Steve. You make some damn fine content, really really excellent.
@richardschloss6410
@richardschloss6410 4 ай бұрын
Now (3 years after the video was posted) there's a pretty neat feature `String.raw`. It helps simplify the function at 10:25 to a one-liner: ``` const f = (strings, ...values) => String.raw({ raw: strings }, ...values.map(i => i.toUpperCase())) ```
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 ай бұрын
I should add String.raw to my video todo list and talk about what it can and can't do.
@rebelmachine88
@rebelmachine88 4 жыл бұрын
Had NO clue about this one. Very helpful video, thanks!
@dputra
@dputra 8 ай бұрын
This is a great way to make html templates using vanilla js. It's what I've been using and it works 👍 Tips: 1. Replace null valued variables to empty strings. This will allows you to do conditional rendering similar to react using the && operator. 2. Join array variables automatically so you can render looping template (cards, table rows, etc.) cleanly. 3. Use "html" as your tagged template literal function name so vscode extensions will pick it up and format them as html.
@LokeshTulsani
@LokeshTulsani 2 жыл бұрын
Very good Explaination. Thanks
@rohanbaikar
@rohanbaikar 4 жыл бұрын
Can you give more examples or provide a link or something inorder to have a more clear idea of how to implement this concept its sure interesting though
@joaovaz3473
@joaovaz3473 4 жыл бұрын
Check out MDN (Mozilla Developers Network) page on tagged template literals, it always has cool examples on its documentation
@paulofernandoee
@paulofernandoee Жыл бұрын
Great video! Thanks.
@golcuk2076
@golcuk2076 2 жыл бұрын
Clearest tagged template video ever, thanks Steve, u are the best.
@joshperry8032
@joshperry8032 Жыл бұрын
Great video, thanks :)
@youngluck66
@youngluck66 Жыл бұрын
Very clear. Thank you.
@hyeonseongnoh7742
@hyeonseongnoh7742 Жыл бұрын
Thank you!!! Kind video
@MrKelbessa
@MrKelbessa 4 жыл бұрын
Hey steve great contents. So here comes the weird suggestion. Have you ever thought about doing a voice over work or reading an audio book? I just think you should at least look in to it. You have a great voice. Any way i love your javascript lessons thank you for making videos.
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
I have considered it and discussed it with another voice actor I know. Just a matter of having the time to do it.
@MrKelbessa
@MrKelbessa 4 жыл бұрын
Steve Griffith Good luck Sir, I’m rooting for you
@bruhmoment3731
@bruhmoment3731 2 жыл бұрын
Gosh you have a great voice!
@demiancoorey2394
@demiancoorey2394 11 ай бұрын
Excellent explanation
@silentstorm8470
@silentstorm8470 4 жыл бұрын
im back again to ask look at this code (i couldnt understand how the keys and value of the objects are passed as parametres on the function) this is the code: const user = { id: 101010, name: "Derek", email: "derek@awesome.com" }; function replace(key, value) { if (typeof value == 'number') { return undefined; } if (key == 'email') { return ' remover for privacy'; } return value; }; //when i console this how does the keys and values from user object are used as parametres in replace function??????? console.log(JSON.stringify(user, replace));
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
This video is about tagged template literal functions, not JSON.stringify. They are different things. kzbin.info/www/bejne/ZpyXf6qfosumsKM - here is my video on stringify.
@silentstorm8470
@silentstorm8470 4 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 srry i just asked here, i didnt know where to ask adn i didnt know that you have a video about stringify thanks
@khgriffi
@khgriffi 3 жыл бұрын
Very helpful. Thank you!!
@mostafagh3573
@mostafagh3573 2 жыл бұрын
great content thank u
@ProjectXH
@ProjectXH 3 жыл бұрын
Thanks for putting the effort to make this video. This is the first time I know about tagged template literals. Also, you sound a bit like a calmer RDJ 😁
@theoligarchist1503
@theoligarchist1503 3 жыл бұрын
cool, looks like a boon for generated JS , generated from other Languages :-)
@bruhmoment3731
@bruhmoment3731 2 жыл бұрын
Rewatching this video after 7 months. I love the pace.
@moooo1743
@moooo1743 2 жыл бұрын
trying to understand this on mdn was a nightmare, thanks Professor Steve!
@howiewang4238
@howiewang4238 3 жыл бұрын
Thank you for this tutorial. It helped me.
@ariyaman90
@ariyaman90 2 жыл бұрын
Hey Steve! Thank you. That was very very understandable
@techlover1219
@techlover1219 4 жыл бұрын
Thank you again. I have a question about the template literal.. When i am using template literal to print a object it is showing [object Object]..but when i am using the traditional way, it is showing the value of the object. Please explain the reason of this behaviour.
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
You must embed a specific object property ${myObj.prop}. If you just try to embed the whole object ${myObj} then you will always get [object Object] because it just does a conversion to String. The String equivalent of EVERY object is [object Object]. This is why you can't use Objects as a keys inside other objects. Every object key must be a String or a Symbol.
@chesterxp508
@chesterxp508 2 жыл бұрын
Another very cool tutorial!
@Lior621
@Lior621 2 жыл бұрын
Such a clear explanation! thank you 😍
@devkushwaha6682
@devkushwaha6682 4 жыл бұрын
According to your Time there I think 4:00 am right now, brother you are making video at that time
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
I schedule the release of my videos. Many of them at 4am UTC.
@chyldstudios
@chyldstudios 2 жыл бұрын
Clear and to the point!
@emmanuelyawson1622
@emmanuelyawson1622 4 жыл бұрын
Thanks, steve how do i get the coordinates appear in real time(updated with little change in position)
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
What coordinates? I'm talking about template strings and functions here.
@khgriffi
@khgriffi 3 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 lol
JavaScript ES6 Reflect Object
8:25
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 11 М.
The Hidden World of requestAnimationFrame
9:22
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 32 М.
Brawl Stars Edit😈📕
00:15
Kan Andrey
Рет қаралды 58 МЛН
小丑妹妹插队被妈妈教训!#小丑#路飞#家庭#搞笑
00:12
家庭搞笑日记
Рет қаралды 38 МЛН
Офицер, я всё объясню
01:00
История одного вокалиста
Рет қаралды 4,6 МЛН
The day of the sea 😂 #shorts by Leisi Crazy
00:22
Leisi Crazy
Рет қаралды 2,3 МЛН
TypeScript Wizardry: Recursive Template Literals
14:47
Tech Talks with Simon
Рет қаралды 38 М.
ES6 Iterator & Generator Fundamentals
18:18
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 31 М.
Tagged Template Literals JavaScript
10:48
techsith
Рет қаралды 9 М.
Templating languages: The hidden costs - Fun Fun Function
28:21
Fun Fun Function
Рет қаралды 50 М.
5 MORE Must Know JavaScript Features That Almost Nobody Knows
18:05
Web Dev Simplified
Рет қаралды 180 М.
Tagged Template Literals
15:32
Kent C. Dodds
Рет қаралды 3,2 М.
Understanding Array flatMap
8:26
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 5 М.
JavaScript Pro Tips - Code This, NOT That
12:37
Fireship
Рет қаралды 2,5 МЛН
Sorting Complex Objects in JavaScript
10:29
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 21 М.
Fast and Beautiful Assembly
34:28
Kay Lack
Рет қаралды 12 М.
Brawl Stars Edit😈📕
00:15
Kan Andrey
Рет қаралды 58 МЛН