Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I manually modify a variable of a JavaScript object at runtime? [duplicate]

This is a silly question, but I was working on an AngularJS app (a simple school project), and wanted to know if there was a way to modify the JavaScript object once it's running in chrome from Chrome's Developer tools. Basically, I have a character and a monster, and I wanted to edit the strength of them in the fight to speed up my debugging process (to avoid setting the value in the source code and then refreshing the page).

My guess is there isn't a way to do that because it could become some "security problem", but I just wasn't sure.


Edit: This is the answer. I just didn't know how to search for it. :)

like image 520
Jacob Holloway Avatar asked Jun 03 '26 12:06

Jacob Holloway


1 Answers

  1. Hit F12
  2. go to the console tab
  3. start executing any javascript.

character.strength = 12 or whatever will work as long as character is globally available.

like image 129
Farzher Avatar answered Jun 06 '26 03:06

Farzher



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!