Chrome Extension: Inject Javascript to set variables [duplicate] - variables

This question already has answers here:
Access variables and functions defined in page context using a content script
(6 answers)
Closed 7 years ago.
How can I inject a <script> to my document which will initialize a variable?
content_script:
$("body").append('<script type="text/javascript">myvar="hi there";</script>');
When I do this, the variable myvar is not recognized...
If I add a simple alert(500); I get the alert.
Basically I just want to pass a variable from the extension the document to use it there.

add var
$("body").append('<script type="text/javascript">var myvar="hi there";</script>');

Related

Why is "interface" not a valid name in IntelliJ? [duplicate]

This question already has answers here:
Cannot create package IntelliJ IDEA
(3 answers)
Closed 6 months ago.
When I add a folder called "interface" in my Scala project in IntelliJ IDEA,
there is a error: "Not a valid package name".
Why is this and is this possible to change?
You can't use reserved keywords.
see the list of reserved keywords:
https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.9

Is it possible to evaluate a variable inside a call read() in karate? [duplicate]

This question already has an answer here:
whats syntax for calling other scenario in same feature file?
(1 answer)
Closed 1 year ago.
demoType is a variable and I want the content of this variable to be what is evaluated in the following expression:
* def call read(demoType)
On the contrary, it tries to evaluate the name of the variable and not its content.
There is no such thing as def call.
Maybe you were trying:
* call read(demoType)
Or:
* def temp = call read(demoType)
Make sure you are on the latest version of Karate. And read the docs: https://github.com/intuit/karate#call-vs-read

what's the difference between arrayListOf and ArrayList in kotlin? [duplicate]

This question already has answers here:
ArrayList<String>() vs arrayListOf<String>()
(5 answers)
Closed 3 years ago.
I searched the difference between arrayListOf and ArrayList.
so I understand arrayListOf is function, and ArrayList is class.
but I don't understand the exact difference using them.
As described in the documentation arrayListOf is a function that creates an ArrayList instance. If I understand it correctly it serves the purpose of determining the generic type from the passed input values and it's a convenience function.

Can I dispatch action with 2 parameters in vuex 3? [duplicate]

This question already has answers here:
Vuex - passing multiple parameters to mutation
(3 answers)
Closed 3 years ago.
Looking at docs
https://vuex.vuejs.org/guide/actions.html
vuejs 2.6 / vuex,3.0.1
do not see if actions can be dispatched with 1 more parameter, as on all these examples?
I tried to dispatch action with 2 parameters, but the second was undefined in action...
Nope you need to dispatch an object with a few fields, if you want a number of parameters.

swift 3 what is better form? [duplicate]

This question already has answers here:
Confused about Swift Array Declarations
(2 answers)
Closed 5 years ago.
I was wondering what is the better way to declare variables?
private var arrayOfStrings: [String] = []
or
private var arrayOfStrings = [String]()
What are the advantages/disadvantages of either solution?
Thanks
As noted here there are little differences in the 2 ways.
Using type annotation you declare which type the variable is, while not using it you let Swift infer the type of the variable.
Almost always Swift will infer the correct type. Be careful:
As you can encounter situations like this in which Swift will have a decision to take. Read the full documentation here.