`_.template` function on array using JavaScript Library underscore.js ( #shorts )

1 year ago
1

Hi Friends,

`_.template` function on array using JavaScript Library underscore.js

`_.template` is also utility function provided by the Underscore.js library that allows you to create a template that can be rendered with data to produce a string output.

In this example, we create a template string that contains a placeholder for the `name` variable, and then pass it to `_.template`. We then create an object with a `name` property and pass it to the template function, which produces the output string "Hello World!".

var templateString = "Hello <%= name %>!";

var template = _.template(templateString);

var result = template({ name: "World" });

console.log(result); // "Hello World!"

#javascript #under #score #underscore #template #underscoretemplate #object #array #string #javascriptinterview #method #js #jquery #function #shorts #viral #popular #latest #new #coders #development #code #dev #interview #php #trend #trending #answer #laravel #youtube #instagram #socialmedia #education #edit #how #india #knowledge #quiz #reels #short #subscribe #share #update #video #web #webdeveloper #website #webdesign #ytshorts #youtuber #princecheema_official @princecheema_official

Loading comments...