小编Ich*_*ile的帖子

How i can do a function who can be applied to any variables at the end of the variable?

I'm trying to do a function like .split() or .replace() or .remove(), i think is like a prototype function, how i can make this example works:

this.logThis = function(a) {
  console.log("The " + this + "is cool like a " + a);
}

var food = "apple";
food.logThis("orange");
Run Code Online (Sandbox Code Playgroud)

To get this Output:

> "The apple is cool like a orange"
Run Code Online (Sandbox Code Playgroud)

Important: I need the most short code possibly, pure javascript, NO JQUERY

javascript

-1
推荐指数
1
解决办法
58
查看次数

标签 统计

javascript ×1