Questions tagged [global-object]

39 questions
24
votes
1 answer

Order between destruction of global object and atexit in C++

I wonder that can sure order between destruction of global object and atexit in C++ I have a global object and register atexit function like below: static MyClass g_class; void onExit() { // do some destruction } int main() { …
zelon
  • 297
  • 2
  • 8
9
votes
3 answers

ReferenceError and the global object

In JavaScript in the browser window is the global object, which means every variable defined in the global scope is a child of window. So why do I get this result: console.log(window.foo); // No error, logs "undefined". console.log(foo); //…
gdoron
  • 147,333
  • 58
  • 291
  • 367
6
votes
2 answers

this keyword in module pattern?

I've just started working at a new company and noticed something that looks completely wrong to me in a lot of their JS. I'm a bit hesitant to bring it up without confirming this is wrong since I'm pretty junior, I'm not a JS expert and it's only my…
Michal
  • 73
  • 6
5
votes
2 answers

Any insights on how to make a canvas drawing not go on top on the other?

It's a preety straight up and basic question. I think that because that must be a often action there must be made function, but I can't find it? Is there one? If there isn't does anybody know how to do it?
raej99
  • 85
  • 5
5
votes
5 answers

Check if a global property/function has been overwritten in JavaScript

JavaScript makes it easy to overwrite properties and functions of the global object. I'd like to find a way to check if the original version of a global property has been replaced. Consider someone putting this in their HTML:
GOTO 0
  • 42,323
  • 22
  • 125
  • 158
4
votes
3 answers

C++ Creating Global Reference of an Object

I am trying to create a global reference of an object but it seems fails or I am getting another error in Qt C++. I have a class called 'System' which holds many objects as members. I want to access System's members from everywhere include members…
3
votes
2 answers

How to iterate through all properties/functions of a global object(library) in v8?

Google apps script provides a library feature, where if you include the project key, a library is added as global object. I'm looking to iterate all functions of a added library. This used to be possible in rhino engine with a for...in loop. But I'm…
TheMaster
  • 45,448
  • 6
  • 62
  • 85
3
votes
1 answer

Node.js url module vs Javascript URL

I was searching for the URL module when I found the URL on both JavaScript and Node.js. I have a few questions: Is the JavaScript URL different from the Node.js URL? What is the difference between the URL module in Node.js and the features of…
Mohsen Movahed
  • 418
  • 5
  • 22
2
votes
1 answer

Why GitHub C++ Core Guideline says that global object better than singleton?

The Github C++ Core Guidelines say: A global object is often better than a singleton. I always thought the opposite. Something has changed since then in the C++? Or may be it's just another typo?
αλεχολυτ
  • 4,792
  • 1
  • 35
  • 71
2
votes
2 answers

Is the "top level context object" in Ruby like the global context in JavaScript?

Suppose I write a Ruby script with not class definition. I can still create class variables and class level instance variables: @@var = "class variable!"; @var = "class instance variable!"; puts @@var; puts @var; These variables belong to a…
Richard JP Le Guen
  • 28,364
  • 7
  • 89
  • 119
1
vote
1 answer

Send function to call() as argument

here in this example function a() { console.log(this.x); } var x = 10; a.x = 20; a.call(a); The result is 20 Why does this happen? I know in call method we can send object but here send a function? can we do that? and why does a.x work?
Mashael
  • 19
  • 2
1
vote
1 answer

How to add fibonacci retracement in interactive plots (plotly)

how to add different color hlines in go.figure add_hline() function previous pyplot function hlines had colors section for adding different colors for pyplot how could i do the same ? # highest_swing and lowest_swings generate the area for which we…
1
vote
1 answer

Why would webpack output with global `self` instead of `this` when output.globalObject: "this" is specified?

I am using webpack-cli 4.7.0. I have a library that I would like to compile for two different environments, one for web and one for node. According to this documentation this is easily achieved my exporting two separate, valid webpack configurations…
Native Coder
  • 1,792
  • 3
  • 16
  • 34
1
vote
4 answers

What is the need of global objects in c++?

I know that C++ also allows to create global objects of class and struct. #include using std::cout; class Test { public: void fun() { cout<<"a= "<
Destructor
  • 14,123
  • 11
  • 61
  • 126
1
vote
0 answers

Play java Request extension

Im catching all requests with OnRequest function ( in my global object). I want to add some information to my request. Im trying to extend the Request class with no success so far... If anyone have any idea on how to add info to every Request im…
1
2 3