Re: Extensions: Why does String.format() work



Hello Eric,

I think this is the gjs magic for string formatting.

SeeĀ https://wiki.gnome.org/Projects/Gjs/Package

pkg.initFormat() will initialize the format module. After calling,
String.prototype.format will be available

Norman

On Sun, 2016-08-21 at 11:26 +0200, elbenfreund wrote:
Hello list,

while browsing some of the existing GNOME-Shell extensions source [1]
noticed string formating similiar to C or python:
``'some_random_string'.format()``.
I'm not really that familiar with JS but by all accounts ([2], [3],
[4])
javascript does not have build in string formating.
So my question is, is there some additional magic happening when JS
is
parsed for extensions? Why does this work? Did I miss something?

Thank you for your time
Eric.

[1]
https://git.gnome.org/browse/gnome-shell-extensions/tree/extensions/d
rive-menu/extension.js#n106
[2]
http://stackoverflow.com/questions/610406/javascript-equivalent-to-pr
intf-string-format
[3]
http://stackoverflow.com/questions/18405736/is-there-a-c-sharp-string
-format-equivalent-in-javascript
[4]
https://developer.mozilla.org/de/docs/Web/JavaScript/Guide/Text_forma
tting



_______________________________________________
gnome-shell-list mailing list
gnome-shell-list gnome org
https://mail.gnome.org/mailman/listinfo/gnome-shell-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]